Package org.insa.graphs.model
Class Graph
- java.lang.Object
-
- org.insa.graphs.model.Graph
-
public final class Graph extends java.lang.ObjectMain graph class.
This class acts as a object-oriented adjacency list for a graph, i.e., it holds a list of nodes and each node holds a list of its successors.
-
-
Constructor Summary
Constructors Constructor Description Graph(java.lang.String mapId, java.lang.String mapName, java.util.List<Node> nodes, GraphStatistics graphStatistics)Create a new graph with the given ID, name, nodes and information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Nodeget(int id)Fetch the node with the given ID.GraphStatisticsgetGraphInformation()java.lang.StringgetMapId()java.lang.StringgetMapName()java.util.List<Node>getNodes()intsize()java.lang.StringtoString()Graphtranspose()
-
-
-
Constructor Detail
-
Graph
public Graph(java.lang.String mapId, java.lang.String mapName, java.util.List<Node> nodes, GraphStatistics graphStatistics)Create a new graph with the given ID, name, nodes and information.- Parameters:
mapId- ID of the map corresponding to this graph.mapName- Name of the map corresponding to this graph.nodes- List of nodes for this graph.graphStatistics- Information for this graph.
-
-
Method Detail
-
getGraphInformation
public GraphStatistics getGraphInformation()
- Returns:
- The GraphStatistics instance associated with this graph.
-
get
public Node get(int id)
Fetch the node with the given ID. Complexity: O(1).- Parameters:
id- ID of the node to fetch.- Returns:
- Node with the given ID.
-
size
public int size()
- Returns:
- Number of nodes in this graph.
-
getNodes
public java.util.List<Node> getNodes()
- Returns:
- List of nodes in this graph (unmodifiable).
- See Also:
Collections.unmodifiableList(List)
-
getMapId
public java.lang.String getMapId()
- Returns:
- ID of the map associated with this graph.
-
getMapName
public java.lang.String getMapName()
- Returns:
- Name of the map associated with this graph.
-
transpose
public Graph transpose()
- Returns:
- Transpose graph of this graph.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-