Graph<DataT,NodeT> Class

  • java.lang.Object
    • com.azure.resourcemanager.resources.fluentcore.dag.Graph<DataT,NodeT>

Type Parameters

DataT

the type of the data stored in the graph's nodes

NodeT

the type of the nodes in the graph

public class Graph<DataT,NodeT>

Type representing a directed graph data structure.

Each node in a graph is represented by Node<DataT,NodeT>

Field Summary

Modifier and Type Field and Description
protected Map<String,NodeT> nodeTable

the nodes in the graph.

Constructor Summary

Constructor Description
Graph()

Creates a directed graph.

Method Summary

Modifier and Type Method and Description
void addNode(NodeT node)

Adds a node to this graph.

protected String findPath(String start, String end)

Find the path.

Collection<NodeT> getNodes()
void visit(Graph.Visitor<Node<DataT,NodeT>> visitor)

Perform DFS visit in this graph.

Methods inherited from java.lang.Object

Field Details

nodeTable

protected Map nodeTable

the nodes in the graph.

Constructor Details

Graph

public Graph()

Creates a directed graph.

Method Details

addNode

public void addNode(NodeT node)

Adds a node to this graph.

Parameters:

node - the node

findPath

protected String findPath(String start, String end)

Find the path.

Parameters:

start - key of first node in the path
end - key of last node in the path

Returns:

string containing the nodes keys in the path separated by arrow symbol

getNodes

public Collection getNodes()

Returns:

all nodes in the graph.

visit

public void visit(Graph.Visitor<>> visitor)

Perform DFS visit in this graph.

The directed graph will be traversed in DFS order and the visitor will be notified as search explores each node and edge.

Parameters:

visitor - the graph visitor

Applies to