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 DirectedEdgecreateEdge(Vertex vertexA, Vertex vertexB, double lengthKm)Create a new link instanceEdgeSegmentcreateEdgeSegment(DirectedEdge parentEdge, boolean directionAB)Create a new physical link segment instanceDirectedEdgecreateUniqueCopyOf(DirectedEdge edgeToCopy)create a shallo copy of the passed in edge, albeit with unique internal idsEdgeSegmentcreateUniqueCopyOf(EdgeSegment edgeSegmentToCopy, DirectedEdge newParentEdge)Create a unique copy of the passed in edge segment.DirectedVertexcreateVertex()Create a new vertex instanceIdGroupingTokengetIdGroupingToken()Collect the id grouping token used by this buildervoidrecreateIds(Edges<? extends DirectedEdge> edges)recreate the ids for all passed in edgesvoidrecreateIds(EdgeSegments<? extends EdgeSegment> edgeSegments)recreate the ids for all passed in edge segmentsvoidrecreateIds(Vertices<? extends DirectedVertex> vertices)recreate the ids for all passed in verticesvoidsetIdGroupingToken(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:
createVertexin 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:
createEdgein 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:
createEdgeSegmentin 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:
setIdGroupingTokenin 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:
getIdGroupingTokenin 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:
recreateIdsin 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:
recreateIdsin 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:
recreateIdsin 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:
createUniqueCopyOfin 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:
createUniqueCopyOfin interfaceDirectedGraphBuilder<DirectedVertex,DirectedEdge,EdgeSegment>- Parameters:
edgeSegmentToCopy- edge segment to copynewParentEdge- use this as the new parent edge- Returns:
- created copy
-
-