Class Graphs

java.lang.Object
org.graylog2.utilities.Graphs

public final class Graphs extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static <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 from graph.
    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>
    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>
    Returns an immutable undirected graph, containing only the specified node.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 from graph.
      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 graph
      node - 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 - A MutableGraph into which all nodes and edges of graph2 will be merged
      graph2 - The Graph whose nodes and edges will be merged into graph1