Skip to content

Commit 4defe08

Browse files
committed
Merge branch 'release/0.6.0'
2 parents ec59eac + 0029a0e commit 4defe08

20 files changed

Lines changed: 455 additions & 134 deletions

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It is designed to be groovy, using closures and metaprogramming for minimal setu
1212

1313
```groovy
1414
#!/usr/bin/env groovy
15-
@Grab(group='com.github.moaxcp', module='graph-dsl', version='0.5.0')
15+
@Grab(group='com.github.moaxcp', module='graph-dsl', version='0.6.0')
1616
import static graph.Graph.graph
1717
1818
graph {
@@ -86,6 +86,13 @@ Contributions are welcome. Please submit a pull request to the develop branch in
8686

8787
# Releases
8888

89+
## 0.6.0
90+
91+
* fixed issue with logging when optimizations are turned off
92+
* updating gradle to 3.4.1
93+
* fixed many codenarc issues
94+
* added support for breadth first traversal
95+
8996
## 0.5.1
9097

9198
* Added warning when optimizations are turned off

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jacocoTestReport {
3636
gradle.taskGraph.whenReady { graph ->
3737
if (graph.hasTask(':jacocoTestReport') || graph.hasTask(':sonarqube')) {
3838
compileGroovy.groovyOptions.optimizationOptions.all = false
39-
log.warn 'all groovy optimizations are turned off for jacoco'
39+
logger.warn 'all groovy optimizations are turned off for jacoco'
4040
}
4141
}
4242

gradle/wrapper/gradle-wrapper.jar

4 Bytes
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Feb 04 14:13:34 EST 2017
1+
#Sat Mar 11 14:54:25 EST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package graph
2+
3+
/**
4+
* Specification for a BreadFirstTraversal. Contains actions that are called
5+
* when an event happens during the traversal.
6+
*/
7+
class BreadthFirstTraversalSpec extends TraversalSpec {
8+
private Closure visitClosure
9+
10+
/**
11+
* Returns the visit closure
12+
* @return
13+
*/
14+
Closure getVisit() {
15+
visitClosure
16+
}
17+
18+
/**
19+
* sets the visit closure
20+
* @param visitClosure
21+
* @return
22+
*/
23+
void visit(Closure visitClosure) {
24+
this.visitClosure = visitClosure
25+
}
26+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package graph
22

3+
/**
4+
* Factory for creating vertices. This factory returns instances of the
5+
* base class Vertex.
6+
*/
37
class DefaultVertexFactory implements VertexFactory {
48
@Override
59
Vertex newVertex(String name) {
6-
return new Vertex(name: name)
10+
new Vertex(name:name)
711
}
812
}
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
11
package graph
22

33
/**
4-
* Specification for a DepthFirstSearch. Contains actions that are called when and
5-
* even happens during the search.
4+
* Specification for a DepthFirstTraversal. Contains actions that are called when an
5+
* event happens during the traversal.
66
*/
7-
class DepthFirstTraversalSpec {
8-
String root
9-
Map colors
10-
private Closure preorder
11-
private Closure postorder
7+
class DepthFirstTraversalSpec extends TraversalSpec {
8+
private Closure preorderClosure
9+
private Closure postorderClosure
1210

1311
/**
1412
* returns the preorder event.
1513
* @return
1614
*/
17-
def getPreorder() {
18-
return preorder
15+
Closure getPreorder() {
16+
preorderClosure
1917
}
2018

2119
/**
2220
* returns the postorder event.
2321
* @return
2422
*/
25-
def getPostorder() {
26-
return postorder
23+
Closure getPostorder() {
24+
postorderClosure
2725
}
2826

2927
/**
3028
* method to set the preorder event
31-
* @param preorder
29+
* @param preorderClosure
3230
* @return
3331
*/
34-
def preorder(Closure preorder) {
35-
this.preorder = preorder
32+
void preorder(Closure preorderClosure) {
33+
this.preorderClosure = preorderClosure
3634
}
3735

3836
/**
3937
* method to set the postorder event
40-
* @param postorder
38+
* @param postorderClosure
4139
* @return
4240
*/
43-
def postorder(Closure postorder) {
44-
this.postorder = postorder
41+
void postorder(Closure postorderClosure) {
42+
this.postorderClosure = postorderClosure
4543
}
4644
}
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
package graph
22

3+
/**
4+
* Represents a directed edge in a grpah. Since these should be soted in a
5+
* Set the equals method is overridden to allow edges in both directions between
6+
* two vertices.
7+
*/
8+
@SuppressWarnings('EqualsAndHashCode') //equals still meets contract with hashCode (I think)
39
class DirectedEdge extends Edge {
410

5-
public boolean equals(Object o) {
11+
/**
12+
* overridden to allow edges in both directions between two vertices.
13+
* @param o
14+
* @return true if two edges are equal.
15+
*/
16+
@SuppressWarnings('Instanceof')
17+
boolean equals(Object o) {
618
if (!(o instanceof DirectedEdge)) {
719
return false
820
}
921
if (this.is(o)) {
1022
return true
1123
}
12-
DirectedEdge rhs = (DirectedEdge) o;
13-
return one == rhs.one && two == rhs.two
24+
DirectedEdge rhs = (DirectedEdge) o
25+
one == rhs.one && two == rhs.two
1426
}
1527
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
package graph
22

3+
/**
4+
* Factory for creating edges. This class returns instances of
5+
* Directed Edge.
6+
*/
37
class DirectedEdgeFactory implements EdgeFactory {
8+
9+
/**
10+
* Returns a new DirectedEdge with the given parameters.
11+
* @param one
12+
* @param two
13+
* @return a new DirectedEdge
14+
*/
415
@Override
516
Edge newEdge(String one, String two) {
6-
return new DirectedEdge(one: one, two: two)
17+
new DirectedEdge(one:one, two:two)
718
}
819
}

src/main/groovy/graph/DirectedGraphPlugin.groovy

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
package graph
22

3+
/**
4+
* This plugin makes a Graph behave like a directed graph.
5+
*/
36
class DirectedGraphPlugin implements Plugin {
47

5-
def apply(Graph graph) {
8+
/**
9+
* The following modifications are made to the graph:
10+
*
11+
* members
12+
* edges - converted to DirectedEdges
13+
* edgeFactory - changed to a DirectedEdgeFactory
14+
*
15+
* methods
16+
* outEdges - returns out going edges from a given vertex name
17+
* adjacentEdges - now only returns outgoing edges from the given vertex name
18+
* @param graph
19+
* @return
20+
*/
21+
void apply(Graph graph) {
622
graph.@edges = graph.@edges.collect { edge ->
7-
new DirectedEdge(one: edge.one, two: edge.two)
23+
new DirectedEdge(one:edge.one, two:edge.two)
824
} as LinkedHashSet
925

1026
graph.edgeFactory = new DirectedEdgeFactory()

0 commit comments

Comments
 (0)