Package org.planit.graph
Class DirectedGraphBuilderImpl
- java.lang.Object
-
- org.planit.graph.DirectedGraphBuilderImpl
-
- All Implemented Interfaces:
DirectedGraphBuilder<DirectedVertex,DirectedEdge,EdgeSegment>
,GraphBuilder<DirectedVertex,DirectedEdge>
public class DirectedGraphBuilderImpl extends Object implements DirectedGraphBuilder<DirectedVertex,DirectedEdge,EdgeSegment>
Create network entities with direction for a physical network simulation model- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description DirectedGraphBuilderImpl(IdGroupingToken groupId)
constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DirectedEdge
createEdge(Vertex vertexA, Vertex vertexB, double lengthKm)
Create a new link instanceEdgeSegment
createEdgeSegment(DirectedEdge parentEdge, boolean directionAB)
Create a new physical link segment instanceDirectedEdge
createUniqueCopyOf(DirectedEdge edgeToCopy)
create a shallo copy of the passed in edge, albeit with unique internal idsEdgeSegment
createUniqueCopyOf(EdgeSegment edgeSegmentToCopy, DirectedEdge newParentEdge)
Create a unique copy of the passed in edge segment.DirectedVertex
createVertex()
Create a new vertex instanceIdGroupingToken
getIdGroupingToken()
Collect the id grouping token used by this buildervoid
recreateIds(Edges<? extends DirectedEdge> edges)
recreate the ids for all passed in edgesvoid
recreateIds(EdgeSegments<? extends EdgeSegment> edgeSegments)
recreate the ids for all passed in edge segmentsvoid
recreateIds(Vertices<? extends DirectedVertex> vertices)
recreate the ids for all passed in verticesvoid
setIdGroupingToken(IdGroupingToken groupToken)
Each builder needs a group if token to allow all underlying factory methods to generated ids uniquely tied to the group the entities belong to
-
-
-
Constructor Detail
-
DirectedGraphBuilderImpl
public DirectedGraphBuilderImpl(IdGroupingToken groupId)
constructor- Parameters:
groupId
- to use for construction of elements
-
-
Method Detail
-
createVertex
public DirectedVertex createVertex()
Create a new vertex instance- Specified by:
createVertex
in interfaceGraphBuilder<DirectedVertex,DirectedEdge>
- Returns:
- created vertex
-
createEdge
public DirectedEdge createEdge(Vertex vertexA, Vertex vertexB, double lengthKm) throws PlanItException
Create a new link instance- Specified by:
createEdge
in interfaceGraphBuilder<DirectedVertex,DirectedEdge>
- Parameters:
vertexA
- the first vertex in this edgevertexB
- the second vertex in this edgelengthKm
- the length (in km)- Returns:
- created edge
- Throws:
PlanItException
- thrown if there is an error
-
createEdgeSegment
public EdgeSegment createEdgeSegment(DirectedEdge parentEdge, boolean directionAB) throws PlanItException
Create a new physical link segment instance- Specified by:
createEdgeSegment
in interfaceDirectedGraphBuilder<DirectedVertex,DirectedEdge,EdgeSegment>
- Parameters:
parentEdge
- the parent edge of the edge segmentdirectionAB
- direction of travel- Returns:
- edgeSegment the created edge segment
- Throws:
PlanItException
- thrown if error
-
setIdGroupingToken
public void setIdGroupingToken(IdGroupingToken groupToken)
Each builder needs a group if token to allow all underlying factory methods to generated ids uniquely tied to the group the entities belong to- Specified by:
setIdGroupingToken
in interfaceGraphBuilder<DirectedVertex,DirectedEdge>
- Parameters:
groupToken
- , contiguous id generation within this group for instances created with the factory methods
-
getIdGroupingToken
public IdGroupingToken getIdGroupingToken()
Collect the id grouping token used by this builder- Specified by:
getIdGroupingToken
in interfaceGraphBuilder<DirectedVertex,DirectedEdge>
- Returns:
- idGroupingToken the id grouping token used by this builder
-
recreateIds
public void recreateIds(Edges<? extends DirectedEdge> edges)
recreate the ids for all passed in edges- Specified by:
recreateIds
in interfaceGraphBuilder<DirectedVertex,DirectedEdge>
- Parameters:
edges
- to recreate ids for
-
recreateIds
public void recreateIds(Vertices<? extends DirectedVertex> vertices)
recreate the ids for all passed in vertices- Specified by:
recreateIds
in interfaceGraphBuilder<DirectedVertex,DirectedEdge>
- Parameters:
vertices
- to recreate ids for
-
recreateIds
public void recreateIds(EdgeSegments<? extends EdgeSegment> edgeSegments)
recreate the ids for all passed in edge segments- Specified by:
recreateIds
in interfaceDirectedGraphBuilder<DirectedVertex,DirectedEdge,EdgeSegment>
- Parameters:
edgeSegments
- to recreate ids for
-
createUniqueCopyOf
public DirectedEdge createUniqueCopyOf(DirectedEdge edgeToCopy)
create a shallo copy of the passed in edge, albeit with unique internal ids- Specified by:
createUniqueCopyOf
in interfaceGraphBuilder<DirectedVertex,DirectedEdge>
- Parameters:
edgeToCopy
- the edge to copy- Returns:
- new edge based on passed in edge
-
createUniqueCopyOf
public EdgeSegment createUniqueCopyOf(EdgeSegment edgeSegmentToCopy, DirectedEdge newParentEdge)
Create a unique copy of the passed in edge segment. All members are copied as is, except for its ids which are created uniquely created so it remains identifiable, also the parent edge is updated if required- Specified by:
createUniqueCopyOf
in interfaceDirectedGraphBuilder<DirectedVertex,DirectedEdge,EdgeSegment>
- Parameters:
edgeSegmentToCopy
- edge segment to copynewParentEdge
- use this as the new parent edge- Returns:
- created copy
-
-