File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
main/java/com/adventofcode/flashk/common/jgrapht
test/java/com/adventofcode/flashk/common/jgrapht Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .adventofcode .flashk .common .jgrapht ;
2+
3+ import org .jgrapht .graph .DefaultEdge ;
4+ import org .jgrapht .nio .Attribute ;
5+ import org .jgrapht .nio .AttributeType ;
6+
7+ /// Labeled edge class based on [JGraphT LabeledEdges](https://jgrapht.org/guide/LabeledEdges)
8+ ///
9+ /// Allows creating an edge with label.
10+ ///
11+ /// It also implements the JGraphT Attribute interface to allow exporting the labels in DOT representation
12+ public class LabeledEdge extends DefaultEdge implements Attribute {
13+
14+ private final String label ;
15+
16+ public LabeledEdge (String label ) {
17+ this .label = label ;
18+ }
19+
20+ @ Override
21+ public String getValue () {
22+ return label ;
23+ }
24+
25+ @ Override
26+ public AttributeType getType () {
27+ return AttributeType .STRING ;
28+ }
29+
30+ @ Override
31+ public String toString () {
32+ return "(" + getSource () + " : " + getTarget () + " : " + label + ")" ;
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ package com .adventofcode .flashk .common .jgrapht ;
2+
3+ import org .jgrapht .nio .AttributeType ;
4+ import org .junit .jupiter .api .Test ;
5+
6+ import static org .junit .jupiter .api .Assertions .*;
7+
8+ class LabeledEdgeTest {
9+
10+ @ Test
11+ void getValue () {
12+ LabeledEdge labeledEdge = new LabeledEdge ("expected" );
13+ assertEquals ("expected" , labeledEdge .getValue ());
14+ }
15+
16+ @ Test
17+ void getType () {
18+ LabeledEdge labeledEdge = new LabeledEdge ("expected" );
19+ assertEquals (AttributeType .STRING , labeledEdge .getType ());
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments