public class LightweightGraph extends Object
Light-weight graphs are hierarchical, in a very simple (and light-weight!) way. Every node can have a "parent" node set for it. Some methods are provided for iterating through the "children" of a given node. Clients that want more complicated or rigid notions of containment can implement it over the top of this API.
Modifier and Type | Class and Description |
---|---|
class |
LightweightGraph.TraversalIterator
The iterator class that is used to iterate over integer
arrays of things and map them into objects.
|
Constructor and Description |
---|
LightweightGraph()
Create a new, empty, light-weight graph
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(LWEdge edge)
Add an edge object to the graph.
|
void |
addNode(LWNode node)
Add a node object to the graph
|
void |
cacheTraversal()
Reconstruct the cache of the topology (this is contained in
a pair of Traversal objects).
|
void |
connect(LWEdge edge,
LWNode tail,
LWNode head)
Connect the given tail and head nodes using the given edge.
|
Iterator |
edges()
Return an iterator over the edges of the graph.
|
LWEdge |
getEdge(int edgeid)
Get the edge with the given id, or null if the edge
does not exist.
|
int |
getEdgeCount()
Get the number of edges in this graph
|
LWNode |
getHeadNode(LWEdge edge)
Get the head node of the given edge
|
LWNode |
getNode(int nodeid)
Get the node with the given id, or null if the edge
does not exist.
|
int |
getNodeCount()
Get the number of nodes in this graph
|
LWNode |
getParent(LWNode node)
Get the parent node of the given node, or null if the node
has no parent (ie is at the root level of the graph).
|
LWNode |
getTailNode(LWEdge edge)
Get the tail node of the given edge
|
Topology |
getTopology()
Get the topology used by this graph.
|
Iterator |
inEdges(LWNode node)
Return an iterator over the edges into the given node.
|
void |
invalidateCache()
Invalidate the cache of the topology.
|
Iterator |
nodes()
Return an iterator over the nodes of the graph.
|
Iterator |
nodes(LWNode parent)
Return an iterator over the nodes that are children of the
given node.
|
Iterator |
outEdges(LWNode node)
Return an iterator over the edges out of the given node.
|
Iterator |
predecessors(LWNode node)
Return an iterator over the predecessors of the given node.
|
void |
removeEdge(LWEdge edge)
Remove the given edge.
|
void |
removeNode(LWNode node)
Remove the given node.
|
Iterator |
roots()
Return an iterator over the root nodes of the graph.
|
void |
setHeadNode(LWEdge edge,
LWNode head)
Set the head node of the given edge.
|
void |
setParent(LWNode node,
LWNode parent)
Set the parent node of the given node.
|
void |
setTailNode(LWEdge edge,
LWNode tail)
Set the tail node of the given edge.
|
Iterator |
successors(LWNode node)
Return an iterator over the successors of the given node.
|
public LightweightGraph()
public void addEdge(LWEdge edge)
public void addNode(LWNode node)
public void cacheTraversal()
public void connect(LWEdge edge, LWNode tail, LWNode head)
public Iterator edges()
public LWEdge getEdge(int edgeid)
public int getEdgeCount()
public Topology getTopology()
public LWNode getNode(int nodeid)
public int getNodeCount()
public LWNode getParent(LWNode node)
public void invalidateCache()
public Iterator nodes()
public Iterator nodes(LWNode parent)
public Iterator outEdges(LWNode node)
public Iterator predecessors(LWNode node)
public void removeEdge(LWEdge edge)
public void removeNode(LWNode node)
public Iterator roots()
public void setHeadNode(LWEdge edge, LWNode head)
public void setParent(LWNode node, LWNode parent)
public void setTailNode(LWEdge edge, LWNode tail)
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.