Created
January 20, 2012 16:07
-
-
Save simonetripodi/1648041 to your computer and use it in GitHub Desktop.
Fluent APIs for Graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge> graph = | |
newUndirectedMutableWeightedGraph( new AbstractGraphConnection<BaseLabeledVertex, BaseLabeledWeightedEdge>() | |
{ | |
public void connect() | |
{ | |
BaseLabeledVertex start = addVertex( new BaseLabeledVertex( "start" ) ); | |
BaseLabeledVertex a = addVertex( new BaseLabeledVertex( "a" ) ); | |
BaseLabeledVertex b = addVertex( new BaseLabeledVertex( "b" ) ); | |
BaseLabeledVertex c = addVertex( new BaseLabeledVertex( "c" ) ); | |
BaseLabeledVertex d = addVertex( new BaseLabeledVertex( "d" ) ); | |
BaseLabeledVertex e = addVertex( new BaseLabeledVertex( "e" ) ); | |
BaseLabeledVertex goal = addVertex( new BaseLabeledVertex( "goal" ) ); | |
addEdge( new BaseLabeledWeightedEdge( "start <-> a", 1.5D ) ).from( start ).to( a ); | |
addEdge( new BaseLabeledWeightedEdge( "start <-> d", 2D ) ).from( start ).to( d ); | |
addEdge( new BaseLabeledWeightedEdge( "a <-> b", 2D ) ).from( a ).to( b ); | |
addEdge( new BaseLabeledWeightedEdge( "b <-> c", 3D ) ).from( b ).to( c ); | |
addEdge( new BaseLabeledWeightedEdge( "c <-> goal", 3D ) ).from( c ).to( goal ); | |
addEdge( new BaseLabeledWeightedEdge( "d <-> e", 3D ) ).from( d ).to( e ); | |
addEdge( new BaseLabeledWeightedEdge( "e <-> goal", 2D ) ).from( e ).to( goal ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment