Package net.automatalib.graph.base
Class AbstractCompactGraph<E extends CompactEdge<EP>,NP,EP>
- java.lang.Object
-
- net.automatalib.graph.base.AbstractCompactGraph<E,NP,EP>
-
- All Implemented Interfaces:
Iterable<Integer>
,FiniteRepresentation
,NodeIDs<Integer>
,Graph<Integer,E>
,Graph.IntAbstraction<E>
,IndefiniteGraph<Integer,E>
,IndefiniteSimpleGraph<Integer>
,MutableGraph<Integer,E,NP,EP>
,MutableGraph.IntAbstraction<E,NP,EP>
,SimpleGraph<Integer>
,SimpleGraph.IntAbstraction
,UniversalGraph<Integer,E,NP,EP>
,UniversalGraph.IntAbstraction<E,NP,EP>
,UniversalIndefiniteGraph<Integer,E,NP,EP>
- Direct Known Subclasses:
AbstractCompactBidiGraph
,CompactGraph
,CompactPMPG
,CompactSimpleGraph
public abstract class AbstractCompactGraph<E extends CompactEdge<EP>,NP,EP> extends Object implements MutableGraph<Integer,E,NP,EP>, MutableGraph.IntAbstraction<E,NP,EP>, NodeIDs<Integer>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.automatalib.graph.MutableGraph
MutableGraph.IntAbstraction<E,NP,EP>
-
-
Constructor Summary
Constructors Constructor Description AbstractCompactGraph()
AbstractCompactGraph(int initialCapacity)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
addIntNode(@Nullable NP property)
Int-abstracted version ofMutableGraph.addNode(Object)
.Integer
addNode(@Nullable NP property)
Adds a new node to the graph.E
connect(int source, int target, @Nullable EP property)
Int-abstracted version ofMutableGraph.connect(Object, Object, Object)
.E
connect(Integer source, Integer target, @Nullable EP property)
Inserts an edge in the graph.protected abstract E
createEdge(int source, int target, @Nullable EP property)
EP
getEdgeProperty(E edge)
Retrieves the property of a given edge.int
getIntTarget(E edge)
Int-abstracted version ofIndefiniteGraph.getTarget(Object)
.Integer
getNode(int id)
Return for a given id the node of the graph identified by it.int
getNodeId(Integer node)
Returns for a given node of the graph an integer uniquely identifying the node.NP
getNodeProperty(Integer node)
Retrieves the property of a given node.Collection<Integer>
getNodes()
Retrieves an (unmodifiable) collection of the nodes in this graph.Collection<E>
getOutgoingEdges(int node)
Int-abstracted version ofGraph.getOutgoingEdges(Object)
.Collection<E>
getOutgoingEdges(Integer node)
Retrieves, for a given node, the (finite) collection of all outgoing edges.Integer
getTarget(E edge)
Retrieves, for a given edge, its target node.NodeIDs<Integer>
nodeIDs()
void
setEdgeProperty(E edge, EP property)
Sets the edge property of the given edge.void
setNodeProperty(Integer node, @Nullable NP property)
Sets the node property of the given node.int
size()
Retrieves the size (number of nodes) of this graph.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.automatalib.graph.Graph
getAdjacentNodes, getOutgoingEdgesIterator, getVisualizationHelper
-
Methods inherited from interface net.automatalib.graph.Graph.IntAbstraction
getEdgesBetween, getOutgoingEdgesIterator, isConnected
-
Methods inherited from interface net.automatalib.graph.IndefiniteGraph
getAdjacentNodesIterator, getEdgesBetween
-
Methods inherited from interface net.automatalib.graph.IndefiniteSimpleGraph
createDynamicNodeMapping, createStaticNodeMapping, isConnected
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface net.automatalib.graph.MutableGraph
addNode, connect
-
Methods inherited from interface net.automatalib.graph.MutableGraph.IntAbstraction
addIntNode, connect, setNodeProperty
-
Methods inherited from interface net.automatalib.graph.SimpleGraph
iterator
-
Methods inherited from interface net.automatalib.graph.UniversalGraph.IntAbstraction
getNodeProperty
-
-
-
-
Method Detail
-
size
public int size()
Description copied from interface:SimpleGraph
Retrieves the size (number of nodes) of this graph.- Specified by:
size
in interfaceFiniteRepresentation
- Specified by:
size
in interfaceSimpleGraph<E extends CompactEdge<EP>>
- Returns:
- the number of nodes of this graph
-
getNodes
public Collection<Integer> getNodes()
Description copied from interface:SimpleGraph
Retrieves an (unmodifiable) collection of the nodes in this graph.- Specified by:
getNodes
in interfaceSimpleGraph<E extends CompactEdge<EP>>
- Returns:
- the nodes in this graph
-
nodeIDs
public NodeIDs<Integer> nodeIDs()
- Specified by:
nodeIDs
in interfaceSimpleGraph<E extends CompactEdge<EP>>
-
getOutgoingEdges
public Collection<E> getOutgoingEdges(Integer node)
Description copied from interface:Graph
Retrieves, for a given node, the (finite) collection of all outgoing edges.- Specified by:
getOutgoingEdges
in interfaceGraph<E extends CompactEdge<EP>,NP>
- Parameters:
node
- the node- Returns:
- a collection containing the outgoing edges
-
getOutgoingEdges
public Collection<E> getOutgoingEdges(int node)
Description copied from interface:Graph.IntAbstraction
Int-abstracted version ofGraph.getOutgoingEdges(Object)
.- Specified by:
getOutgoingEdges
in interfaceGraph.IntAbstraction<E extends CompactEdge<EP>>
-
getTarget
public Integer getTarget(E edge)
Description copied from interface:IndefiniteGraph
Retrieves, for a given edge, its target node.- Specified by:
getTarget
in interfaceIndefiniteGraph<E extends CompactEdge<EP>,NP>
- Parameters:
edge
- the edge.- Returns:
- the target node of the given edge.
-
getIntTarget
public int getIntTarget(E edge)
Description copied from interface:Graph.IntAbstraction
Int-abstracted version ofIndefiniteGraph.getTarget(Object)
.- Specified by:
getIntTarget
in interfaceGraph.IntAbstraction<E extends CompactEdge<EP>>
-
addNode
public Integer addNode(@Nullable NP property)
Description copied from interface:MutableGraph
Adds a new node to the graph.- Specified by:
addNode
in interfaceMutableGraph<Integer,E extends CompactEdge<EP>,NP,EP>
- Parameters:
property
- the property for the new node- Returns:
- the newly inserted node
-
addIntNode
public int addIntNode(@Nullable NP property)
Description copied from interface:MutableGraph.IntAbstraction
Int-abstracted version ofMutableGraph.addNode(Object)
.- Specified by:
addIntNode
in interfaceMutableGraph.IntAbstraction<E extends CompactEdge<EP>,NP,EP>
-
setNodeProperty
public void setNodeProperty(Integer node, @Nullable NP property)
Description copied from interface:MutableGraph
Sets the node property of the given node.- Specified by:
setNodeProperty
in interfaceMutableGraph<Integer,E extends CompactEdge<EP>,NP,EP>
- Parameters:
node
- the nodeproperty
- the property to set
-
connect
public E connect(Integer source, Integer target, @Nullable EP property)
Description copied from interface:MutableGraph
Inserts an edge in the graph.- Specified by:
connect
in interfaceMutableGraph<Integer,E extends CompactEdge<EP>,NP,EP>
- Parameters:
source
- the source node of the edgetarget
- the target node of the edgeproperty
- the property of the edge- Returns:
- the newly inserted edge
-
connect
public E connect(int source, int target, @Nullable EP property)
Description copied from interface:MutableGraph.IntAbstraction
Int-abstracted version ofMutableGraph.connect(Object, Object, Object)
.- Specified by:
connect
in interfaceMutableGraph.IntAbstraction<E extends CompactEdge<EP>,NP,EP>
-
setEdgeProperty
public void setEdgeProperty(E edge, EP property)
Description copied from interface:MutableGraph
Sets the edge property of the given edge.- Specified by:
setEdgeProperty
in interfaceMutableGraph<Integer,E extends CompactEdge<EP>,NP,EP>
- Specified by:
setEdgeProperty
in interfaceMutableGraph.IntAbstraction<E extends CompactEdge<EP>,NP,EP>
- Parameters:
edge
- the edgeproperty
- the property to set
-
getNodeId
public int getNodeId(Integer node)
Description copied from interface:NodeIDs
Returns for a given node of the graph an integer uniquely identifying the node. The returned ids should be within the range of the number of states of the graph so that they can be used for array-based indexing.- Specified by:
getNodeId
in interfaceNodeIDs<E extends CompactEdge<EP>>
- Parameters:
node
- the node whose id should be retrieved- Returns:
- the (positive) id of the given graph node.
-
getNode
public Integer getNode(int id)
Description copied from interface:NodeIDs
Return for a given id the node of the graph identified by it.- Specified by:
getNode
in interfaceNodeIDs<E extends CompactEdge<EP>>
- Parameters:
id
- the id of the node to be returned- Returns:
- the graph node identified by the given
id
.
-
getNodeProperty
public NP getNodeProperty(Integer node)
Description copied from interface:UniversalIndefiniteGraph
Retrieves the property of a given node.- Specified by:
getNodeProperty
in interfaceUniversalIndefiniteGraph<Integer,E extends CompactEdge<EP>,NP,EP>
- Parameters:
node
- the node- Returns:
- the property of the specified node
-
getEdgeProperty
public EP getEdgeProperty(E edge)
Description copied from interface:UniversalIndefiniteGraph
Retrieves the property of a given edge.- Specified by:
getEdgeProperty
in interfaceUniversalGraph.IntAbstraction<E extends CompactEdge<EP>,NP,EP>
- Specified by:
getEdgeProperty
in interfaceUniversalIndefiniteGraph<Integer,E extends CompactEdge<EP>,NP,EP>
- Parameters:
edge
- the edge- Returns:
- the property of the specified edge
-
-