Class SimpleGraph<T extends Node>

java.lang.Object
org.tweetyproject.graphs.DefaultGraph<T>
org.tweetyproject.graphs.SimpleGraph<T>
Type Parameters:
T - the type of the node
All Implemented Interfaces:
Iterable<T>, GeneralGraph<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 Details

    • 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 Details

    • addAll

      public boolean addAll(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(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(Collection<? extends T> nodesA, 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
    • addSubGraph

      public boolean addSubGraph(T superExit, SimpleGraph<T> subGraph, T subEntry, String label) throws NoSuchObjectException
      Adds a graph as a subgraph
      Parameters:
      superExit - Node of the this graph, under which the new graph will be anchored
      subGraph - Graph, which will be added to the super-graph
      subEntry - Node of the subgraph, which will be connected to the super-graph
      label - Label of the newly created edge, from the superExit node to the subRoot node
      Throws:
      NoSuchObjectException - Thrown if superExit is not a node of this graph