tangle 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7619bcb426ea03ee0855fbc4d0f61d03fcd24b325a1c2a370adee95b74d483d0
4
- data.tar.gz: cfa7d21bcce74e0b9931e4b581ad0fdff593b531b7f075db3ee25a92e1044ade
3
+ metadata.gz: ee78865b571dbfbc96822cb208d01eea82658dac5c553c8b25e3b991dc7e961b
4
+ data.tar.gz: a85db9accf74b1ef91b25fcf90362794edea78dae51509ffb02d6f522c86f59c
5
5
  SHA512:
6
- metadata.gz: '028079643873be046dce5457dfc90cc7c7215bfbf78a8cfe894d47bcdf818218fcae2b7ad8bf0837c135be26377b8b5d5d2849dfba6e640b3443a47000f5a625'
7
- data.tar.gz: 3c254ca0cb877f0b6871778782bb91d3499967e8d5256963d8b487b3d7c042f7aa61fd078484607bbdfbd85eba9601b4e3e68854fce24c47411e1cb6f8791c5f
6
+ metadata.gz: 61859d678645444dc8529c23fda328348995867446b27016bdd18d6e08e4c2270af0f7eec1b77eb299c683d42a7ff711a50f3659822b5202a11416fa02ad5cc5
7
+ data.tar.gz: 2b0174a54065b6f9e13ad02edbe5da19870eb08de332c3bf0deaccf94a15428eeb81c458aafa0f379361d5099ac629fa57aaec9f77f7f50cc0e469a3d16232b8
@@ -0,0 +1,20 @@
1
+ require 'tangle/directed/edge'
2
+
3
+ module Tangle
4
+ module Directed
5
+ module Acyclic
6
+ #
7
+ # An edge in a directed acyclic graph
8
+ #
9
+ class Edge < Tangle::Directed::Edge
10
+ private
11
+
12
+ def validate_edge
13
+ super
14
+ raise CyclicError if @parent.ancestor?(@child) ||
15
+ @child.descendant?(@parent)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ require 'tangle/directed/graph'
2
+ require 'tangle/directed/acyclic/edge'
3
+
4
+ module Tangle
5
+ module Directed
6
+ module Acyclic
7
+ #
8
+ # A directed acyclic graph
9
+ class Graph < Tangle::Directed::Graph
10
+ Edge = Tangle::Directed::Acyclic::Edge
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/tangle/errors.rb CHANGED
@@ -25,4 +25,12 @@ module Tangle
25
25
  super
26
26
  end
27
27
  end
28
+
29
+ # CyclicError is raised when an edge cycle is disallowed.
30
+ #
31
+ class CyclicError < RuntimeError
32
+ def initialize(reason = 'cycles not allowed', *)
33
+ super
34
+ end
35
+ end
28
36
  end
data/lib/tangle.rb CHANGED
@@ -3,6 +3,7 @@ require 'tangle/errors'
3
3
  require 'tangle/graph'
4
4
  require 'tangle/simple/graph'
5
5
  require 'tangle/directed/graph'
6
+ require 'tangle/directed/acyclic/graph'
6
7
 
7
8
  # Tangle manages various types of graphs
8
9
  #
@@ -12,8 +13,15 @@ require 'tangle/directed/graph'
12
13
  # Tangle::SimpleGraph.new
13
14
  # => Undirected graph with single edges between vertices, and no loops
14
15
  #
16
+ # Tangle::DiGraph.new
17
+ # => Directed graph without edge constraints
18
+ #
19
+ # Tangle::DAG.new
20
+ # => Directed graph with no edge cycles
21
+ #
15
22
  module Tangle
16
23
  MultiGraph = Tangle::Graph
17
24
  SimpleGraph = Tangle::Simple::Graph
18
25
  DiGraph = Tangle::Directed::Graph
26
+ DAG = Tangle::Directed::Acyclic::Graph
19
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tangle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calle Englund
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-07 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git-version-bump
@@ -99,6 +99,8 @@ files:
99
99
  - bin/console
100
100
  - bin/setup
101
101
  - lib/tangle.rb
102
+ - lib/tangle/directed/acyclic/edge.rb
103
+ - lib/tangle/directed/acyclic/graph.rb
102
104
  - lib/tangle/directed/edge.rb
103
105
  - lib/tangle/directed/graph.rb
104
106
  - lib/tangle/edge.rb