Package org.goplanit.graph
Class UntypedGraphImpl<V extends Vertex,E extends Edge>
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.graph.UntypedGraphImpl<V,E>
-
- All Implemented Interfaces:
Comparable<IdAble>
,UntypedGraph<V,E>
,IdAble
,ManagedId
- Direct Known Subclasses:
ConjugateGraphImpl
,GraphImpl
,UntypedDirectedGraphImpl
public class UntypedGraphImpl<V extends Vertex,E extends Edge> extends IdAbleImpl implements UntypedGraph<V,E>
A graph implementation consisting of vertices and edges- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected GraphEntities<E>
edges
class instance containing all edgesprotected GraphEntities<V>
vertices
class instance containing all vertices-
Fields inherited from interface org.goplanit.utils.graph.UntypedGraph
GRAPH_ID_CLASS
-
-
Constructor Summary
Constructors Constructor Description UntypedGraphImpl(UntypedGraphImpl<V,E> other, boolean deepCopy)
Copy constructor for shallow copyUntypedGraphImpl(UntypedGraphImpl<V,E> other, boolean deepCopy, GraphEntityDeepCopyMapper<V> vertexMapper, GraphEntityDeepCopyMapper<E> edgesMapper)
Copy constructor for shallow copyUntypedGraphImpl(IdGroupingToken groupId, GraphEntities<V> vertices, GraphEntities<E> edges)
Graph Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UntypedGraph<V,E>
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.protected static long
generatedGraphId(IdGroupingToken groupId)
Generate a graph idGraphEntities<E>
getEdges()
collect edges of graphIdGroupingToken
getGraphIdGroupingToken()
Collect the id grouping token used for all entities registered on the graph, i.e., this graph specific identifier for generating ids unique and contiguous within this network and this network onlyClass<UntypedGraph>
getIdClass()
Each managed id class is expected to generate its ids based on its class signature.GraphEntities<V>
getVertices()
collect vertices of graphlong
recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable idUntypedGraph<V,E>
shallowClone()
Create a shallow copy of this entityUntypedGraphImpl<V,E>
smartDeepClone(GraphEntityDeepCopyMapper<V> vertexMapper, GraphEntityDeepCopyMapper<E> edgeMapper)
A smart deep clone updates known interdependencies between vertices, edges, and edge segments utilising the graph entity deep copy mappers-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, generateId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
resetChildManagedIdEntities
-
Methods inherited from interface org.goplanit.utils.graph.UntypedGraph
isEmpty, transformGeometries, validate
-
-
-
-
Field Detail
-
edges
protected final GraphEntities<E extends Edge> edges
class instance containing all edges
-
vertices
protected final GraphEntities<V extends Vertex> vertices
class instance containing all vertices
-
-
Constructor Detail
-
UntypedGraphImpl
public UntypedGraphImpl(IdGroupingToken groupId, GraphEntities<V> vertices, GraphEntities<E> edges)
Graph Constructor- Parameters:
groupId
- contiguous id generation within this group for instances of this classvertices
- to useedges
- to use
-
UntypedGraphImpl
public UntypedGraphImpl(UntypedGraphImpl<V,E> other, boolean deepCopy)
Copy constructor for shallow copy- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwise
-
UntypedGraphImpl
public UntypedGraphImpl(UntypedGraphImpl<V,E> other, boolean deepCopy, GraphEntityDeepCopyMapper<V> vertexMapper, GraphEntityDeepCopyMapper<E> edgesMapper)
Copy constructor for shallow copy- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwisevertexMapper
- to use for tracking mapping between original and copied verticesedgesMapper
- to use for tracking mapping between original and copied edges
-
-
Method Detail
-
generatedGraphId
protected static long generatedGraphId(IdGroupingToken groupId)
Generate a graph id- Parameters:
groupId
- to use- Returns:
- the generated id
-
getGraphIdGroupingToken
public IdGroupingToken getGraphIdGroupingToken()
Collect the id grouping token used for all entities registered on the graph, i.e., this graph specific identifier for generating ids unique and contiguous within this network and this network only- Returns:
- the graph id grouping token
-
recreateManagedIds
public long recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable id- Specified by:
recreateManagedIds
in interfaceManagedId
- Parameters:
tokenId
- to use (may be null in case managed id entity does not rely on token to recreate its managed id(s))- Returns:
- the updated internal id
-
getIdClass
public Class<UntypedGraph> getIdClass()
Each managed id class is expected to generate its ids based on its class signature. To be able to generate the correct id the class used for id generation is to be provided via this method call.- Specified by:
getIdClass
in interfaceManagedId
- Returns:
- idClass to use for generating ids for instances of this idable derived class
-
getVertices
public GraphEntities<V> getVertices()
collect vertices of graph- Specified by:
getVertices
in interfaceUntypedGraph<V extends Vertex,E extends Edge>
- Returns:
- vertices
-
getEdges
public GraphEntities<E> getEdges()
collect edges of graph
-
shallowClone
public UntypedGraph<V,E> shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceUntypedGraph<V extends Vertex,E extends Edge>
- Specified by:
shallowClone
in classIdAbleImpl
- Returns:
- shallow copy of entity
-
deepClone
public UntypedGraph<V,E> deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in interfaceUntypedGraph<V extends Vertex,E extends Edge>
- Specified by:
deepClone
in classIdAbleImpl
- Returns:
- deep copy of entity
-
smartDeepClone
public UntypedGraphImpl<V,E> smartDeepClone(GraphEntityDeepCopyMapper<V> vertexMapper, GraphEntityDeepCopyMapper<E> edgeMapper)
A smart deep clone updates known interdependencies between vertices, edges, and edge segments utilising the graph entity deep copy mappers- Parameters:
vertexMapper
- tracking original to copy mappingsedgeMapper
- tracking original to copy mappings- Returns:
- created copy
-
-