GraphDFS

scalation.database.graph_pm.GraphDFS
class GraphDFS(g: Graph, bfs: Boolean)

The GraphDFS performs Depth First Search (DFS) or Breadth First Search (BFS) on a Directed Graph. The class currently supports three predicates: (1) to find a matching label, and (2) to see if a destination vertex is reachable.

Value parameters

bfs

switch from DFS to BFS, if bfs flag is true (defaults to false)

g

the directed graph to search

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Type members

Types

type QUEUE = Queue[Int]
type STACK = Stack[Int]

Value members

Concrete methods

def find(_lab: ValueType): Int

Find the label lab in this graph, returning the first vertex id with a matching label, or -1 if vertex is not found.

Find the label lab in this graph, returning the first vertex id with a matching label, or -1 if vertex is not found.

Value parameters

_lab

the label to search for

Attributes

def pred1(j: Int): Boolean
def pred2(j: Int): Boolean
def reach(src: Int, _dest: Int): Boolean

Determine whether vertex _dest is reachable from src, i.e., there is a directed path from vertex src to _dest.

Determine whether vertex _dest is reachable from src, i.e., there is a directed path from vertex src to _dest.

Value parameters

_dest

the destination/ending vertex

src

the source/starting vertex

Attributes

def strongComps: Int

Count the number of strongly connected components in the graph. In a strongly connected component, reach (u, v) is always true.

Count the number of strongly connected components in the graph. In a strongly connected component, reach (u, v) is always true.

Attributes

def visit(pred: Int => Boolean): Int

Visit vertices in DFS/BFS order, returning the id of the first vertex satisfying the predicate pred, or -1 if vertex is not found.

Visit vertices in DFS/BFS order, returning the id of the first vertex satisfying the predicate pred, or -1 if vertex is not found.

Value parameters

pred

the predicate to satisfy

Attributes

def visit(): Unit

Visit vertices in DFS/BFS order accessing children and parents (as if it is an undirected graph).

Visit vertices in DFS/BFS order accessing children and parents (as if it is an undirected graph).

Value parameters

pred

the predicate to satisfy

Attributes

def weakComps: Int

Count the number of weakly connected components in the graph. In a weakly connected component, the vertices in the underlying undirected graph are connected.

Count the number of weakly connected components in the graph. In a weakly connected component, the vertices in the underlying undirected graph are connected.

Attributes