Package org.graylog2.utilities
Class Graphs
java.lang.Object
org.graylog2.utilities.Graphs
-
Method Summary
Modifier and TypeMethodDescriptionstatic <N> com.google.common.graph.ImmutableGraph<N>
Returns an empty directed graph (immutable).static <N> com.google.common.graph.ImmutableGraph<N>
emptyGraph
(com.google.common.graph.Graph<N> graph) Returns an empty graph (immutable) initialized with all properties queryable fromgraph
.static <N> com.google.common.graph.ImmutableGraph<N>
Returns an empty undirected graph (immutable).static <N> void
merge
(com.google.common.graph.MutableGraph<N> graph1, com.google.common.graph.Graph<N> graph2) Merge all nodes and edges of two graphs.static <N> com.google.common.graph.ImmutableGraph<N>
singletonDirectedGraph
(N node) Returns an immutable directed graph, containing only the specified node.static <N> com.google.common.graph.ImmutableGraph<N>
singletonGraph
(com.google.common.graph.Graph<N> graph, N node) Returns an immutable graph, containing only the specified node.static <N> com.google.common.graph.ImmutableGraph<N>
singletonUndirectedGraph
(N node) Returns an immutable undirected graph, containing only the specified node.
-
Method Details
-
emptyDirectedGraph
public static <N> com.google.common.graph.ImmutableGraph<N> emptyDirectedGraph()Returns an empty directed graph (immutable).- Type Parameters:
N
- The class of the nodes- Returns:
- an empty directed graph
-
emptyUndirectedGraph
public static <N> com.google.common.graph.ImmutableGraph<N> emptyUndirectedGraph()Returns an empty undirected graph (immutable).- Type Parameters:
N
- The class of the nodes- Returns:
- an empty undirected graph
-
emptyGraph
public static <N> com.google.common.graph.ImmutableGraph<N> emptyGraph(com.google.common.graph.Graph<N> graph) Returns an empty graph (immutable) initialized with all properties queryable fromgraph
.- Type Parameters:
N
- The class of the nodes- Parameters:
graph
- The graph to use as template for the created graph- Returns:
- an empty graph
- See Also:
-
GraphBuilder.from(Graph)
-
singletonDirectedGraph
public static <N> com.google.common.graph.ImmutableGraph<N> singletonDirectedGraph(N node) Returns an immutable directed graph, containing only the specified node.- Type Parameters:
N
- The class of the nodes- Parameters:
node
- The single node in the returned graph- Returns:
- an immutable directed graph with a single node
-
singletonUndirectedGraph
public static <N> com.google.common.graph.ImmutableGraph<N> singletonUndirectedGraph(N node) Returns an immutable undirected graph, containing only the specified node.- Type Parameters:
N
- The class of the nodes- Parameters:
node
- The single node in the returned graph- Returns:
- an immutable undirected graph with a single node
-
singletonGraph
public static <N> com.google.common.graph.ImmutableGraph<N> singletonGraph(com.google.common.graph.Graph<N> graph, N node) Returns an immutable graph, containing only the specified node.- Type Parameters:
N
- The class of the nodes- Parameters:
graph
- The graph to use as template for the created graphnode
- The single node in the returned graph- Returns:
- an immutable graph with a single node
- See Also:
-
GraphBuilder.from(Graph)
-
merge
public static <N> void merge(com.google.common.graph.MutableGraph<N> graph1, com.google.common.graph.Graph<N> graph2) Merge all nodes and edges of two graphs.- Type Parameters:
N
- The class of the nodes- Parameters:
graph1
- AMutableGraph
into which all nodes and edges of graph2 will be mergedgraph2
- TheGraph
whose nodes and edges will be merged into graph1
-