DirectedGraph

public class DirectedGraph
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.DirectedGraph<V>


A directed unweighted graphs implementation. The vertex type can be specified.

Summary

Public constructors

DirectedGraph()

Public methods

void addEdge(V from, V to)

Add an edge to the graph; if either vertex does not exist, it's added.

void addVertice(V vertex)

Add a vertex to the graph.

boolean contains(V vertex)

True if graph contains vertex.

boolean isDag()

True if graph is a dag (directed acyclic graph).

void removeEdge(V from, V to)

Remove an edge from the graph.

String toString()

String representation of graph.

Public constructors

DirectedGraph

DirectedGraph ()

Public methods

addEdge

void addEdge (V from, 
                V to)

Add an edge to the graph; if either vertex does not exist, it's added. This implementation allows the creation of multi-edges and self-loops.

Parameters
from V
to V

addVertice

void addVertice (V vertex)

Add a vertex to the graph. Inop if vertex is already in graph.

Parameters
vertex V

contains

boolean contains (V vertex)

True if graph contains vertex. False otherwise.

Parameters
vertex V
Returns
boolean

isDag

boolean isDag ()

True if graph is a dag (directed acyclic graph).

Returns
boolean

removeEdge

void removeEdge (V from, 
                V to)

Remove an edge from the graph.

Parameters
from V
to V
Throws
IllegalArgumentException if either vertex doesn't exist.

toString

String toString ()

String representation of graph.

Returns
String