case class Graph[N, A, B](rep: GraphRep[N, A, B]) extends Product with Serializable
An implementation of an inductive graph where nodes of type
N
are labeled with A
, and edges are labeled with B
.
- Alphabetic
- By Inheritance
- Graph
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
&(ctx: Context[N, A, B]): Graph[N, A, B]
Alias for
embed
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addEdge(e: LEdge[N, B]): Graph[N, A, B]
Add an edge to this graph.
Add an edge to this graph. Throws an error if the source and target nodes don't exist in the graph.
-
def
addEdges(es: Seq[LEdge[N, B]]): Graph[N, A, B]
Add multiple edges to this graph
-
def
addNode(n: LNode[N, A]): Graph[N, A, B]
Add a node to this graph.
Add a node to this graph. If this node already exists with a different label, its label will be replaced with this new one.
-
def
addNodes(vs: Seq[LNode[N, A]]): Graph[N, A, B]
Add multiple nodes to this graph
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bf(q: Queue[Path[N]]): RTree[N]
Utility function for breadth-first search trees.
-
def
bfe(v: N): Seq[Edge[N]]
Breadth-first search remembering predecessor information.
Breadth-first search remembering predecessor information. Gives transient edges in breadth-first order, starting from the given node.
-
def
bfen(es: Seq[Edge[N]]): Seq[Edge[N]]
Breadth-first search remembering predecessor information.
Breadth-first search remembering predecessor information. Gives transient edges starting from the targets of the given edges, in breadth-first order.
-
def
bfenInternal(q: Queue[Edge[N]]): Vector[Edge[N]]
Utility function for breadth-first search, remembering predecessor information.
-
def
bfs(v: N): Seq[N]
Breadth-first search from the given node.
Breadth-first search from the given node. The result is ordered by distance from the node
v
. -
def
bfsWith[C](f: (Context[N, A, B]) ⇒ C, v: N): Seq[C]
Breadth-first search from the given node.
Breadth-first search from the given node. The result is a vector of results of passing the context of each visited to the function
f
. -
def
bfsn(vs: Seq[N]): Seq[N]
Breadth-first search from the given nodes.
Breadth-first search from the given nodes. The result is the successors of
vs
, with immediate successors first. -
def
bfsnInternal[C](f: (Context[N, A, B]) ⇒ C, q: Queue[N]): Vector[C]
Utility function for breadth-first search (nodes ordered by distance)
-
def
bfsnWith[C](f: (Context[N, A, B]) ⇒ C, vs: Seq[N]): Seq[C]
Breadth-first search from the given nodes.
Breadth-first search from the given nodes. The result is a vector of results of passing the context of each visited node to the function
f
. -
def
bft(v: N): RTree[N]
Breadth-first search tree.
Breadth-first search tree. The result is a list of paths through the graph from the given vertex, in breadth-first order.
-
def
bidecomp(first: N, last: N): Option[BiDecomp[N, A, B]]
Returns a context focused on two nodes designated "first" and "last", if present, and the graph with those nodes removed.
-
def
cheapestPath[C](s: N, t: N, costFkt: (LNode[N, A], B, LNode[N, A]) ⇒ C)(implicit arg0: Monoid[C], arg1: Ordering[C]): Option[LPath[N, B]]
Cheapest path from vertex
s
to vertext
under the cost functioncostFkt
with labels -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
contains(v: N): Boolean
Returns true if the given node is in the graph, otherwise false
-
def
context(v: N): Context[N, A, B]
Find the context for the given node.
Find the context for the given node. Causes an error if the node is not present in the graph.
-
def
contextGraph: Graph[N, Context[N, A, B], B]
Get all the contexts of this graph, as a graph.
-
def
contexts: Vector[Context[N, A, B]]
Get all the contexts in the graph, as a vector.
Get all the contexts in the graph, as a vector. Note that the resulting contexts may overlap, in the sense that successive contexts in the result will contain vertices from previous contexts as well.
-
def
countNodes: Int
The number of nodes in this graph
-
def
decomp(n: N): Decomp[N, A, B]
Returns a context focused on the given node, if present, and the graph with that node removed.
-
def
decompAny: Decomp[N, A, B]
Decompose this graph into the context for an arbitrarily chosen node and the rest of the graph.
-
def
degree(v: N): Int
The number of connections to and from the given node
-
def
dff(vs: Seq[N]): Vector[Tree[N]]
Depth-first forest.
Depth-first forest. Follows successors of the given nodes. The result is a vector of trees of nodes where each path in each tree is a path through the graph.
-
def
dffWith[C](vs: Seq[N], f: (Context[N, A, B]) ⇒ C): Vector[Tree[C]]
Depth-first forest.
Depth-first forest. Follows successors of the given nodes. The result is a vector of trees of results of passing the context of each node to the function
f
. -
def
dfs(vs: Seq[N]): Seq[N]
Forward depth-first search.
-
def
dfsWith[C](vs: Seq[N], f: (Context[N, A, B]) ⇒ C): Seq[C]
Forward depth-first search.
-
def
edges: Vector[Edge[N]]
A list of all the edges in the graph
-
def
efilter(f: (LEdge[N, B]) ⇒ Boolean): Graph[N, A, B]
The subgraph containing only edges that match the property
-
def
elfilter(f: (B) ⇒ Boolean): Graph[N, A, B]
The subgraph containing only edges whose labels match the property
-
def
emap[C](f: (B) ⇒ C): Graph[N, A, C]
Map a function over the edge labels in the graph
-
def
embed(ctx: Context[N, A, B]): Graph[N, A, B]
Embed the given context in the graph.
Embed the given context in the graph. If the context's vertex is already in the graph, removes the old context from the graph first. This operation is the deterministic inverse of
decomp
and obeys the following laws:(g & c) decomp c.vertex == Decomp(Some(c), g)
(g decomp c.vertex).rest & c == (g & c)
-
def
endBy(f: (Graph[N, A, B], N) ⇒ Seq[N]): Seq[N]
Find all nodes that match the given ending criteria.
-
def
endNode(f: (Graph[N, A, B], N) ⇒ Seq[N], n: N): Boolean
Check if the given node is an end node according to the given criteria.
Check if the given node is an end node according to the given criteria. An ending node
n
in graphg
hasf(g,n)
containing no nodes other thann
. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
esp(s: N, t: N): Option[Path[N]]
The shortest path from vertex
s
to vertext
-
def
filterMap[C, D](f: (Context[N, A, B]) ⇒ Option[Context[N, C, D]]): Graph[N, C, D]
Build a graph out of a partial map of the contexts in this graph.
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
findEdge(e: Edge[N]): Option[LEdge[N, B]]
Find an edge between two nodes
-
def
fold[C](u: C)(f: (Context[N, A, B], C) ⇒ C): C
Fold a function over the graph.
Fold a function over the graph. Note that each successive context received by the function will not contain vertices at the focus of previously received contexts. The first context will be an arbitrarily chosen context of this graph, but the next context will be arbitrarily chosen from a graph with the first context removed, and so on.
-
def
foldAll[C](u: C)(f: (Context[N, A, B], C) ⇒ C): C
Fold a function over all the contexts in the graph.
Fold a function over all the contexts in the graph. Each context received by the function will be an arbitrarily chosen context of this graph. Contrary to
fold
, this visits every node of the graph and gives you all incoming and outgoing adjacencies for each node. -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
gmap[C, D](f: (Context[N, A, B]) ⇒ Context[N, C, D]): Graph[N, C, D]
Map a function over the graph
-
def
hasLoop: Boolean
Check if this graph has any loops, which connect a node to itself.
-
def
hasMulti: Boolean
Check if this graph has multiple edges connecting any two nodes
-
def
inDegree(v: N): Int
The number of inbound edges from the given node
-
def
inEdges(v: N): Vector[LEdge[N, B]]
Find all inbound edges for the given node
-
def
ins(v: N): Adj[N, B]
All the inbound links of the given node, including self-edges
-
def
isEmpty: Boolean
Check if the graph is empty
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isLeaf(n: N): Boolean
Check if the given node is a leaf of this graph
-
def
isRoot(n: N): Boolean
Check if the given node is a root of this graph
-
def
isSimple: Boolean
Check whether this graph is simple.
Check whether this graph is simple. A simple graph has no loops and no multi-edges.
-
def
labEdges: Vector[LEdge[N, B]]
A list of all the edges in the graph and their labels
-
def
labNodes: Vector[LNode[N, A]]
A list of all the nodes in the graph and their labels
-
def
label(v: N): Option[A]
Find the label for a node
-
def
labfilter(p: (A) ⇒ Boolean): Graph[N, A, B]
The subgraph containing only nodes whose labels match the property
-
def
labnfilter(p: (LNode[N, A]) ⇒ Boolean): Graph[N, A, B]
The subgraph containing only labelled nodes that match the property
-
def
lbf(q: Queue[LPath[N, B]]): LRTree[N, B]
Utility function for labeled breadth-first search tree
-
def
lbft(v: N): LRTree[N, B]
Breadth-first search tree with labeled paths
-
def
leaves: Set[N]
Find the leaves of the graph.
Find the leaves of the graph. A leaf is a node which as no outgoing edges.
-
def
lesp(s: N, t: N): Option[LPath[N, B]]
Shortest path from vertex
s
to vertext
, with labels -
def
level(v: N): Seq[(N, Int)]
Breadth-first search giving the distance of each node from the node
v
. -
def
leveln(vs: Seq[(N, Int)]): Seq[(N, Int)]
Breadth-first search giving the distance of each node from the search nodes.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
neighbors(v: N): Vector[N]
Find the neighbors of a node
-
def
nfilter(p: (N) ⇒ Boolean): Graph[N, A, B]
The subgraph containing only nodes that match the property
-
def
nmap[C](f: (A) ⇒ C): Graph[N, C, B]
Map a function over the node labels in the graph
-
def
nodes: Vector[N]
A list of all the nodes in the graph
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
outDegree(v: N): Int
The number of outbound edges from the given node
-
def
outEdges(v: N): Vector[LEdge[N, B]]
Find all outbound edges for the given node
-
def
outs(v: N): Adj[N, B]
All the outbound links of the given node, including self-edges
-
def
predecessors(v: N): Vector[N]
Find all nodes that have a link to the given node
-
def
rdfs(vs: Seq[N]): Seq[N]
Reverse depth-first search.
Reverse depth-first search. Follows predecessors.
-
def
reachable(v: N): Vector[N]
Finds all the reachable nodes from a given node, using DFS
-
def
redecorate[C](f: (Context[N, A, B]) ⇒ C): Graph[N, C, B]
Map a function over the contexts of this graph, and put the results in the labels.
-
def
removeEdge(e: Edge[N]): Graph[N, A, B]
Remove an edge from this graph
-
def
removeEdges(es: Seq[Edge[N]]): Graph[N, A, B]
Remove multiple edges from this graph
-
def
removeLEdge(e: LEdge[N, B]): Graph[N, A, B]
Remove an edge from this graph only if the label matches
-
def
removeNode(v: N): Graph[N, A, B]
Remove a node from this graph
-
def
removeNodes(vs: Seq[N]): Graph[N, A, B]
Remove multiple nodes from this graph
- val rep: GraphRep[N, A, B]
-
def
reverse: Graph[N, A, B]
Reverse the direction of all edges
-
def
roots: Set[N]
Find the roots of the graph.
Find the roots of the graph. A root is a node which has no incoming edges.
-
def
safeAddEdge(e: LEdge[N, B], failover: ⇒ Graph[N, A, B] = this): Graph[N, A, B]
Add an edge to this graph.
Add an edge to this graph. If the source and target nodes don't exist in this graph, return the given
failover
graph. -
def
safeAddEdges(es: Seq[LEdge[N, B]]): Graph[N, A, B]
Add multiple edges to this graph, ignoring edges whose source and target nodes don't already exist in the graph.
-
def
select(p: (Context[N, A, B]) ⇒ Boolean): Vector[Context[N, A, B]]
Project out (non-overlapping) contexts for which the given property is true.
Project out (non-overlapping) contexts for which the given property is true. Note that the contexts will not overlap, in the sense that successive contexts in the result will not contain the vertices at the focus of previous contexts.
-
def
selectAll(p: (Context[N, A, B]) ⇒ Boolean): Vector[Context[N, A, B]]
Get all the contexts for which the given property is true.
Get all the contexts for which the given property is true. Note that the resulting contexts may overlap, in the sense that successive contexts in the result may contain vertices from previous contexts.
-
def
subgraph(vs: Seq[N]): Graph[N, A, B]
The subgraph containing only the given nodes
-
def
successors(v: N): Vector[N]
Find all nodes that have a link from the given node
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tclose: Graph[N, A, Unit]
Finds the transitive closure of this graph.
-
def
toString(): String
- Definition Classes
- Graph → AnyRef → Any
-
def
udfs(vs: Seq[N]): Seq[N]
Undirected depth-first search
-
def
undir: Graph[N, A, B]
Make the graph undirected, ensuring that every edge has an inverse.
Make the graph undirected, ensuring that every edge has an inverse. This takes edge labels into account when considering whether two edges are equal.
-
def
union(g: Graph[N, A, B]): Graph[N, A, B]
Adds all the nodes and edges from one graph to another.
-
def
unlabel: Graph[N, Unit, Unit]
Erase all labels in the graph
-
def
updateEdge(e: LEdge[N, B]): Graph[N, A, B]
Replace an edge with a new one
-
def
updateEdges(es: Seq[LEdge[N, B]]): Graph[N, A, B]
Update multiple edges
-
def
updateNode(n: LNode[N, A]): Graph[N, A, B]
Replace a node with a new one
-
def
updateNodes(ns: Seq[LNode[N, A]]): Graph[N, A, B]
Update multiple nodes
-
def
vmap[M](f: (N) ⇒ M): Graph[M, A, B]
Map over the unique node identifiers in the graph
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
xdfWith[C](vs: Seq[N], d: (Context[N, A, B]) ⇒ Seq[N], f: (Context[N, A, B]) ⇒ C): (Vector[Tree[C]], Graph[N, A, B])
Generalized depth-first forest.
Generalized depth-first forest. Uses the function
d
to decide which nodes to visit next -
def
xdffWith[C](vs: Seq[N], d: (Context[N, A, B]) ⇒ Seq[N], f: (Context[N, A, B]) ⇒ C): Vector[Tree[C]]
Generalized depth-first forest.
Generalized depth-first forest. Uses the function
d
to decide which nodes to visit next. -
final
def
xdfsWith[C](vs: Seq[N], d: (Context[N, A, B]) ⇒ Seq[N], f: (Context[N, A, B]) ⇒ C): Vector[C]
Generalized depth-first search.
Inherited from Serializable
Inherited from Serializable
Inherited from Product
Inherited from Equals
Inherited from AnyRef
Inherited from Any
Basic Graph Operations
Graph Decomposition
Structural decomposition of a graph
Graph Composition
Deletion and Modification
Projection
Functions for extracting global information about a graph
Graph Inspection
Functions for extracting information about individual nodes and edges in a graph
Folds and Maps
Subgraphs
Depth-First Search
Algorithms for depth-first traversal.
Breadth-First Search
Algorithms for breadth-first traversal.
Roots and Leaves
Queries to find starting and ending nodes, roots, and leaves.
Graph Classification
Classification functions on graphs