Class DirectionTransformer
java.lang.Object
edu.uci.ics.jung.algorithms.transformation.DirectionTransformer
Functions for transforming graphs into directed or undirected graphs.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <V,
E> Graph <V, E> toDirected
(Graph<V, E> graph, com.google.common.base.Supplier<DirectedGraph<V, E>> graph_factory, com.google.common.base.Supplier<E> edge_factory, boolean create_new) Transformsgraph
(which may be of any directionality) into a directed graph.static <V,
E> UndirectedGraph <V, E> toUndirected
(Graph<V, E> graph, com.google.common.base.Supplier<UndirectedGraph<V, E>> graph_factory, com.google.common.base.Supplier<E> edge_factory, boolean create_new) Transformsgraph
(which may be of any directionality) into an undirected graph.
-
Constructor Details
-
DirectionTransformer
public DirectionTransformer()
-
-
Method Details
-
toUndirected
public static <V,E> UndirectedGraph<V,E> toUndirected(Graph<V, E> graph, com.google.common.base.Supplier<UndirectedGraph<V, E>> graph_factory, com.google.common.base.Supplier<E> edge_factory, boolean create_new) Transformsgraph
(which may be of any directionality) into an undirected graph. (This may be useful for visualization tasks). Specifically:- Vertices are copied from
graph
. - Directed edges are 'converted' into a single new undirected edge in the new graph.
- Each undirected edge (if any) in
graph
is 'recreated' with a new undirected edge in the new graph ifcreate_new
is true, or copied fromgraph
otherwise.
- Type Parameters:
V
- the vertex typeE
- the edge type- Parameters:
graph
- the graph to be transformedgraph_factory
- used to create the new graph objectedge_factory
- used to create new edgescreate_new
- specifies whether existing undirected edges are to be copied or recreated- Returns:
- the transformed
Graph
- Vertices are copied from
-
toDirected
public static <V,E> Graph<V,E> toDirected(Graph<V, E> graph, com.google.common.base.Supplier<DirectedGraph<V, E>> graph_factory, com.google.common.base.Supplier<E> edge_factory, boolean create_new) Transformsgraph
(which may be of any directionality) into a directed graph. Specifically:- Vertices are copied from
graph
. - Undirected edges are 'converted' into two new antiparallel directed edges in the new graph.
- Each directed edge (if any) in
graph
is 'recreated' with a new edge in the new graph ifcreate_new
is true, or copied fromgraph
otherwise.
- Type Parameters:
V
- the vertex typeE
- the edge type- Parameters:
graph
- the graph to be transformedgraph_factory
- used to create the new graph objectedge_factory
- used to create new edgescreate_new
- specifies whether existing directed edges are to be copied or recreated- Returns:
- the transformed
Graph
- Vertices are copied from
-