public class LabeledDigraph extends Object
NodeLabel and are represented by integers.
Edges can be labeled with arbitrary objects and are identified by their source node and either
their label or their position on the sequence of outgoing edges of a node.
Note that multiple edges between two nodes as well as loops are allowed.| Modifier and Type | Field and Description |
|---|---|
static int |
INVALID
Integer representing an invalid element of a LabeledDigraph.
|
| Constructor and Description |
|---|
LabeledDigraph(int capacity)
Creates a new LabeledDigraph.
|
LabeledDigraph(LabeledDigraph digraph)
Creates a deep copy of a given LabeledDigraph.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(int from,
Object label,
int to)
Adds a new edge from node from to node to that is labeled with label
provided that the two nodes exists and label is not null.
|
void |
addNode(NodeLabel label,
int successorCapacity,
int predecessorCapacity)
Adds a new node with the provided label.
|
boolean |
containsEdgeLabel(int node,
Object label) |
boolean |
containsNode(int value) |
Object |
edgeLabelAt(int node,
int pos) |
List<Object> |
edgeLabelsFromTo(int from,
int to)
Determines a list of all edge labels with source node 'from' and
target node 'to'.
|
int |
externalNodeAt(int pos) |
int |
externalPosOf(int node)
Determines the position of a given node in the sequence of external nodes.
|
boolean |
isExternal(int node) |
boolean |
isPacked() |
NodeLabel |
nodeLabelOf(int node) |
List<Object> |
outgoingEdgeLabelsOf(int node) |
int[] |
pack()
Transforms this LabeledDigraph into a more compact form
in which the size of the underlying data structures containsSubsumingState
no "wholes" due to invalid elements anymore.
|
int |
posOfEdgeLabel(int node,
Object label)
Determines the position of an outgoing edge with the provided
label of the provided node.
|
int |
predecessorSizeOf(int node) |
gnu.trove.list.array.TIntArrayList |
predecessorsOf(int node) |
int |
rank() |
boolean |
removeEdgeAt(int node,
int pos)
Removes the outgoing edge of node that is at position pos.
|
boolean |
removeEdgeLabelAt(int node,
Object label)
Removes the outgoing edge of node 'node' that is labeled with 'label'
|
boolean |
removeNodeAt(int node) |
void |
replaceEdgeLabel(int node,
Object oldLabel,
Object newLabel)
Replaces all outgoing edges of the given node that are labeled with oldLabel
by edges labeled with newLabel.
|
void |
replaceNodeLabel(int node,
NodeLabel newLabel)
Sets the label of a node to newLabel.
|
void |
setExternal(int node)
Marks the provided node as external
|
int |
size() |
int |
successorSizeOf(int node) |
gnu.trove.list.array.TIntArrayList |
successorsOf(int node) |
String |
toString() |
void |
unsetExternal(int node) |
public static final int INVALID
public LabeledDigraph(int capacity)
capacity - The initial capacity in terms of number of nodes that can be
stored without increasing the size of underlying data structures.public LabeledDigraph(LabeledDigraph digraph)
digraph - The original graph.public int size()
public void addNode(NodeLabel label, int successorCapacity, int predecessorCapacity)
label - The label of the new node.successorCapacity - The number of successor nodes that can be added to
this node without increasing underlying data structures.predecessorCapacity - The number of predecessor nodes that can be added to this
this node without increasing underlying data structures.public NodeLabel nodeLabelOf(int node)
node - The requested node.public boolean containsNode(int value)
value - The value that should be checked whether it corresponds to a node.public boolean removeNodeAt(int node)
node - The node that should be removed.public void addEdge(int from,
Object label,
int to)
from - The source node of the new edge.label - The label of the new edge.to - The target of the new edge.public int successorSizeOf(int node)
node - A node in the graph.public boolean isPacked()
public int predecessorSizeOf(int node)
node - The node whose predecessor nodes are requested.public List<Object> outgoingEdgeLabelsOf(int node)
node - A node in the graph.public Object edgeLabelAt(int node, int pos)
node - The node whose outgoing edges are considered.
More precisely, all edges having node as source are considered.pos - Ask for the outgoing edge of node at position pos.public boolean removeEdgeAt(int node,
int pos)
node - The source node whose outgoing edges are considered.pos - The position determining which edge should be removed.public boolean removeEdgeLabelAt(int node,
Object label)
node - The node whose outgoing edges are considered.label - The label of the edge that should be removed.public int posOfEdgeLabel(int node,
Object label)
node - The node whose outgoing edges are considered.label - The label of the edge whose position should be determined.INVALID if no such edge exists.public void setExternal(int node)
node - The node that should be marked as external.public int rank()
public int externalPosOf(int node)
node - The node whose position should be determined.INVALID is returned.public boolean isExternal(int node)
node - The node to be checked.public void unsetExternal(int node)
node - The node that should be removed from the sequence of external nodes.public void replaceEdgeLabel(int node,
Object oldLabel,
Object newLabel)
node - The node whose outgoing edges are considered.oldLabel - The edge label that should be replaced.newLabel - The edge label used to replace oldLabel.public boolean containsEdgeLabel(int node,
Object label)
node - The node whose outgoing edges should be considered.label - The edge label to look for.public gnu.trove.list.array.TIntArrayList predecessorsOf(int node)
node - The node whose predecessors are considered.public gnu.trove.list.array.TIntArrayList successorsOf(int node)
node - The node whose successor nodes are considered.public List<Object> edgeLabelsFromTo(int from, int to)
from - The source node.to - The target node.public int[] pack()
public int externalNodeAt(int pos)
public void replaceNodeLabel(int node,
NodeLabel newLabel)
node - The node.newLabel - The new label of the node.Copyright © 2018. All rights reserved.