Package org.planit.graph
Class EdgesImpl<V extends Vertex,E extends Edge>
- java.lang.Object
-
- org.planit.graph.EdgesImpl<V,E>
-
-
Constructor Summary
Constructors Constructor Description EdgesImpl(GraphBuilder<V,E> graphBuilder)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
get(long id)
Get edge by idboolean
isEmpty()
Check if is emptyIterator<E>
iterator()
E
register(E edge)
Add edge to the internal container.E
registerNew(Vertex vertexA, Vertex vertexB, double length, boolean registerOnVertices)
Create new edge to network identified via its id, allow to be registered on vertices if indicated)E
registerUniqueCopyOf(E edgeToCopy)
copy the passed in edge and register itvoid
remove(long edgeId)
remove an edge.void
remove(E edge)
remove an edge.int
size()
Get the number of edges in the graphprotected void
updateIdMapping()
updates the edge map keys based on edge ids in case an external force has changed already registered edges-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.graph.Edges
registerNew
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
EdgesImpl
public EdgesImpl(GraphBuilder<V,E> graphBuilder)
Constructor- Parameters:
graphBuilder
- the builder for edge implementations
-
-
Method Detail
-
updateIdMapping
protected void updateIdMapping()
updates the edge map keys based on edge ids in case an external force has changed already registered edges
-
register
public E register(E edge)
Add edge to the internal container. Do not use this unless you know what you are doing because it can mess up the contiguous internal id structure of the edges. PReferred method is to only use registerNew.- Parameters:
edge
- edge to be registered in this network based on its internal id- Returns:
- edge, in case it overrides an existing edge, the removed edge is returned
-
remove
public void remove(E edge)
remove an edge.
-
remove
public void remove(long edgeId)
remove an edge.
-
registerNew
public E registerNew(Vertex vertexA, Vertex vertexB, double length, boolean registerOnVertices) throws PlanItException
Create new edge to network identified via its id, allow to be registered on vertices if indicated)- Specified by:
registerNew
in interfaceEdges<V extends Vertex>
- Parameters:
vertexA
- the first vertex in this edgevertexB
- the second certex in this edgelength
- the length of this edgeregisterOnVertices
- choice to register new edge on the vertices or not- Returns:
- the created edge
- Throws:
PlanItException
- thrown if there is an error
-
get
public E get(long id)
Get edge by id
-
size
public int size()
Get the number of edges in the graph
-
isEmpty
public boolean isEmpty()
Check if is empty
-
registerUniqueCopyOf
public E registerUniqueCopyOf(E edgeToCopy)
copy the passed in edge and register it- Specified by:
registerUniqueCopyOf
in interfaceEdges<V extends Vertex>
- Parameters:
edgeToCopy
- as is except for its ids which will be updated to makeit uniquely identifiable- Returns:
- copy of edge now registered
-
-