Class SimpleGraph<T extends Node>

  • Type Parameters:
    T - the type of the node
    All Implemented Interfaces:
    java.lang.Iterable<T>, Graph<T>

    public class SimpleGraph<T extends Node>
    extends DefaultGraph<T>
    implements Graph<T>
    An extended version of the DefaultGraph which supports removing of nodes as well as some utility functions for d-separation
    Author:
    Lars Bengel
    • Constructor Detail

      • SimpleGraph

        public SimpleGraph​(Graph<T> graph)
        create a copy of the given graph
        Parameters:
        graph - some graph
      • SimpleGraph

        public SimpleGraph()
        create a new SimpleGraph instance
    • Method Detail

      • addAll

        public boolean addAll​(java.util.Collection<? extends T> c)
        add all nodes to the graph
        Parameters:
        c - a collection of nodes
        Returns:
        true iff all nodes are added
      • addAllEdges

        public boolean addAllEdges​(java.util.Collection<Edge<T>> c)
        add all edges to the graph
        Parameters:
        c - a collection of edges
        Returns:
        true iff all edges are added
      • remove

        public boolean remove​(T node)
        remove the given node from the graph
        Parameters:
        node - some node
        Returns:
        true iff the structure has been changed
      • remove

        public boolean remove​(Edge<T> edge)
        remove the given edge from the graph
        Parameters:
        edge - some edge
        Returns:
        true iff the structure has changed
      • areDisconnected

        public boolean areDisconnected​(java.util.Collection<? extends T> nodesA,
                                       java.util.Collection<? extends T> nodesB)
        Compute whether nodesA and nodesB are disconnected and thus d-separated in the graph
        Parameters:
        nodesA - a set of arguments
        nodesB - a set of arguments
        Returns:
        true iff argsA and argsB are disconnected in the graph
      • toUndirectedGraph

        public SimpleGraph<T> toUndirectedGraph()
        convert the graph into a undirected graph
        Returns:
        the undirected graph