com.kuka.graph
Class GraphBuilder<N,E,G extends Graph<N,E>>

java.lang.Object
  extended by com.kuka.graph.GraphBuilder<N,E,G>
Type Parameters:
N - the type of nodes contained in the graph
E - the type of edges contained in the graph
G - the type of the graph

public final class GraphBuilder<N,E,G extends Graph<N,E>>
extends Object

Helper class for building graphs.

See Also:
Graph

Method Summary
 GraphBuilder<N,E,G> addEdge(E edge)
          Adds the specified edge to the graph if it is not already present.
 GraphBuilder<N,E,G> addEdge(N source, N target)
          Adds an edge from the specified source to the specified target node to the graph if it is not already present.
 GraphBuilder<N,E,G> addGraph(G graph)
          Adds all nodes and edges contained in the specified graph if they are not already present.
 GraphBuilder<N,E,G> addNode(N node)
          Adds the specified node to the graph if it is not already present.
 G build()
          Builds the graph.
static
<N,E,G extends Graph<N,E>>
GraphBuilder<N,E,G>
create(G graph)
          Creates a new graph builder for the given graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static <N,E,G extends Graph<N,E>> GraphBuilder<N,E,G> create(G graph)
Creates a new graph builder for the given graph.

Type Parameters:
N - the type of nodes contained in the graph
E - the type of edges contained in the graph
G - the type of the graph
Parameters:
graph - the graph to create a builder for
Returns:
the graph builder for the specified graph

addNode

public GraphBuilder<N,E,G> addNode(N node)
Adds the specified node to the graph if it is not already present.

Parameters:
node - node to be added to the graph
Returns:
this graph builder

addEdge

public GraphBuilder<N,E,G> addEdge(E edge)
Adds the specified edge to the graph if it is not already present.

Parameters:
edge - edge to be added to the graph
Returns:
this graph builder

addEdge

public GraphBuilder<N,E,G> addEdge(N source,
                                   N target)
Adds an edge from the specified source to the specified target node to the graph if it is not already present.

Parameters:
source - the source node of the edge that is to be created
target - the target node of the edge that is to be created
Returns:
this graph builder

addGraph

public GraphBuilder<N,E,G> addGraph(G graph)
Adds all nodes and edges contained in the specified graph if they are not already present.

Parameters:
graph - the graph to add
Returns:
this graph builder

build

public G build()
Builds the graph.

Returns:
the graph


Copyright © 2019. All rights reserved.