class Graph extends Cloneable
The Graph
class stores vertex-labeled directed graphs using an adjacency
set 'ch' representation, e.g., 'ch = { {1, 2}, {0}, {1} }' means that the
graph has the following edges { (0, 1), (0, 2), (1, 0), (2, 1) }.
Optionally, inverse adjacency via the 'pa' array can be stored at the cost
of nearly doubling the storage requirements.
----------------------------------------------------------------------------
- Alphabetic
- By Inheritance
- Graph
- Cloneable
- Cloneable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
def
addPar(): Unit
Add the inverse adjacency sets for rapid accesses to parent vertices.
-
def
buildLabelMap(label: Array[TLabel]): Map[TLabel, Set[Int]]
Given an array of labels, return an index from labels to the sets of vertices containing those labels.
Given an array of labels, return an index from labels to the sets of vertices containing those labels.
- label
the array of vertex labels of type
TLabel
- val ch: Array[Set[Int]]
-
def
checkEdges: Boolean
Check whether the end-point vertex id of each edge is within bounds: 0 ..
Check whether the end-point vertex id of each edge is within bounds: 0 .. 'maxId'.
-
def
clone(): Graph
Clone (make a deep copy) of this graph.
Clone (make a deep copy) of this graph.
- Definition Classes
- Graph → AnyRef
-
def
getVerticesWithLabel(l: TLabel): Set[Int]
Return the set of vertices in the graph with label l.
- val inverse: Boolean
-
def
isConnected: Boolean
Determine whether 'this' graph is (weakly) connected.
- val label: Array[TLabel]
-
val
labelMap: Map[TLabel, Set[Int]]
The map from label to the set of vertices with the label
-
def
nEdges: Int
Return the number of edges in the graph.
-
def
nSelfLoops: Int
Determine the number of vertices in the graph that have outgoing edges to themselves (self loops).
- val name: String
-
val
pa: Array[Set[Int]]
The optional array of vertex inverse (parent) adjacency sets (incoming edges)
-
def
printG(clip: Boolean = true): Unit
Print 'this' graph in a deep sense with all the information.
Print 'this' graph in a deep sense with all the information.
- clip
whether to clip out "Set(" and ")"
-
def
same(g: Graph): Boolean
Determine whether 'this' graph and graph 'g' have the same vertices and edges.
Determine whether 'this' graph and graph 'g' have the same vertices and edges. Note, this is more strict than graph isomorphism which allows vertices to be renumbered.
- g
the other digraph
-
def
size: Int
Return the number of vertices in the graph.
-
def
toLine(i: Int, clip: Boolean = true): String
Convert the 'i'th row/line of 'this' graph to a string.
Convert the 'i'th row/line of 'this' graph to a string.
- i
the 'i'th row/line
- clip
whether to clip out "Set(" and ")"
-
def
toString(): String
Convert 'this' graph to a string in a shallow sense.
Convert 'this' graph to a string in a shallow sense. Large arrays are not converted. Use 'print' to show all information.
- Definition Classes
- Graph → AnyRef → Any