Package edu.claflin.finder.logic

# Class ConditionedGraph

java.lang.Object
edu.claflin.finder.logic.Graph
edu.claflin.finder.logic.ConditionedGraph

public class ConditionedGraph extends Graph
Represents a "conditioned" graph. A conditioned graph is restrained and limited by the conditions applied to the graph upon creation.

Version:
  1.1 May 28, 2015
Author:
  Charles Allen Schultz II

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `private final List<Condition>`
  `conditions`
  The List of Conditions applied to this Graph.
  `private boolean`
  `forceSatisfactionOnAdd`
  A boolean indicating whether or not conditions are forced when components are added to the network.

  ### Fields inherited from class edu.claflin.finder.logic.Graph

  `suppressLog`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `private`
  `ConditionedGraph(Graph graph, Collection<Condition> conditions)`
  Private constructor used to create copies of ConditionedGraph objects.
  ``
  `ConditionedGraph(String graphName)`
  Public constructor for creating a simple ConditionedGraph.
  ``
  `ConditionedGraph(String graphName, Collection<Condition> conditions)`
  Public constructor for creating a ConditionedGraph.
  ``
  `ConditionedGraph(String graphName, Collection<Condition> conditions, boolean forceOnAdd)`
  Public constructor for creating a ConditionedGraph.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCondition(Condition condition)`
  Adds a condition to the graph.
  `boolean`
  `addPartialGraph(List<Node> nodes, List<Edge> edges)`
  Adds a partial graph to this graph.
  `private ConditionedGraph`
  `conditionOther(Graph graph)`
  Private method used for copying the ConditionedGraph.
  `ConditionedGraph`
  `copy()`
  Copies this Graph object using the getSubGraph() method.
  `boolean`
  `forcesOnAdd()`
  Returns true if conditions are forced on addition of new network components.
  `List<Condition>`
  `getConditionsList()`
  Returns an accessible list of conditions.
  `boolean`
  `querySatisfaction()`
  Used to query if the ConditionedGraph fits its applied conditions.
  `void`
  `removeCondition(Condition condition)`
  Removes a condition from the graph.
  `void`
  `setForceOnAdd(boolean forceSatisfactionOnAdd)`
  Accessor method for configuring if conditions are forced on add of network components.
  `private void`
  `superAddPartialGraph(List<Node> nodes, List<Edge> edges)`
  Private method for circumventing the condition restrictions.
  `String`
  `toString()`
  Returns a String representation of the Graph.
  `ConditionedGraph`
  `uniqueCopy()`
  Copies this Graph producing a unique copy in which there is no entanglement between the two Graph objects.

  ### Methods inherited from class edu.claflin.finder.logic.Graph

  `addEdge, addEdge, addEdge, addEdges, addNewNode, addNode, addNodes, containsNode, crosstalk, difference, getAdjacencyList, getEdge, getEdge, getEdge, getEdgeCount, getEdgeList, getEdgesBack, getGraphWeight, getName, getNode, getNodeCount, getNodeEdges, getNodeIndex, getNodeIndex, getNodeList, getNodeName, getPartiteSets, getSubGraph, getSubGraph, getSubGraph, intersect, isBipartite, isClique, removeEdge, removeNode, toStringNameless, transpose, transpose, transpose, union, uniqueCopy`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### conditions

    private final List<Condition> conditions
    The List of Conditions applied to this Graph.

  - ### forceSatisfactionOnAdd

    private boolean forceSatisfactionOnAdd
    A boolean indicating whether or not conditions are forced when components are added to the network. If true, a simulation is run before adding Nodes or Edges to determine if the conditions will hold afterwards.

- ## Constructor Details

  - ### ConditionedGraph

    public ConditionedGraph(String graphName)
    Public constructor for creating a simple ConditionedGraph. Has no conditions applied to it.
    Parameters:
      `graphName` - the String representing the name of the graph.

  - ### ConditionedGraph

    public ConditionedGraph(String graphName, Collection<Condition> conditions)
    Public constructor for creating a ConditionedGraph. Applies some conditions.
    Parameters:
      `graphName` - the String representing the name of the graph.
      `conditions` - the Collection<Condition> containing the Condition objects.

  - ### ConditionedGraph

    public ConditionedGraph(String graphName, Collection<Condition> conditions, boolean forceOnAdd)
    Public constructor for creating a ConditionedGraph. Applies some conditions as well as configuring if conditions should be forced.
    Parameters:
      `graphName` - the String representing the name of the graph.
      `conditions` - the Collection <Condition> containing the Condition objects.
      `forceOnAdd` - the boolean indicating if conditions should be forced.

  - ### ConditionedGraph

    private ConditionedGraph(Graph graph, Collection<Condition> conditions)
    Private constructor used to create copies of ConditionedGraph objects.
    Parameters:
      `graph` - a normal Graph object without conditions.
      `conditions` - a collection of conditions to apply.

- ## Method Details

  - ### addCondition

    public void addCondition(Condition condition)
    Adds a condition to the graph.
    Parameters:
      `condition` - the Condition to add.

  - ### removeCondition

    public void removeCondition(Condition condition)
    Removes a condition from the graph.
    Parameters:
      `condition` - the Condition to remove.

  - ### getConditionsList

    public List<Condition> getConditionsList()
    Returns an accessible list of conditions. It CAN be manipulated outside the graph's control, in which case it can be updated externally, however it is NOT thread safe.
    Returns:
      a List of Conditions.

  - ### forcesOnAdd

    public boolean forcesOnAdd()
    Returns true if conditions are forced on addition of new network components.
    Returns:
      true if conditions are forced; false otherwise.

  - ### setForceOnAdd

    public void setForceOnAdd(boolean forceSatisfactionOnAdd)
    Accessor method for configuring if conditions are forced on add of network components.
    Parameters:
      `forceSatisfactionOnAdd` - a boolean indicating if conditions should be forced.

  - ### querySatisfaction

    public boolean querySatisfaction()
    Used to query if the ConditionedGraph fits its applied conditions.
    Returns:
      true if the graph satisfies its conditions.

  - ### addPartialGraph

    public boolean addPartialGraph(List<Node> nodes, List<Edge> edges)
    Adds a partial graph to this graph. Specifically adds a set of nodes and a set of edges to the graph. It should be noted that nodes or edges in the graph already that attempt to be added again may cause exceptions to occur. Additionally, Nodes are added before Edges so any Edges that depend on Nodes in the add list may be safely added simultaneously. This method is the backbone structure for adding any component to the graph as all other addition methods filter through here.

    Runs a simulation if the ConditionedGraph is configured to check first that additions will be adhered to. Allows a user to incrementally build a graph and determine at which point the graph no longer abides by its conditions.

    Overrides:
      `addPartialGraph` in class `Graph`
    Parameters:
      `nodes` - the List<Node> containing the nodes to add.
      `edges` - the List<Edge> containing the edges to add.
    Returns:
      true if the addition abides by the conditions of the graph.

  - ### superAddPartialGraph

    private void superAddPartialGraph(List<Node> nodes, List<Edge> edges)
    Private method for circumventing the condition restrictions. Used by `addPartialGraph(java.util.List, java.util.List)` for simulating a graph expansion.
    Parameters:
      `nodes` - the List<Node> containing the nodes to add.
      `edges` - the List<Edge> containing the edges to add.

  - ### conditionOther

    private ConditionedGraph conditionOther(Graph graph)
    Private method used for copying the ConditionedGraph. Applies the current conditions and satisfaction variables to the supplied Graph to create a ConditionedGraph.
    Parameters:
      `graph` - an unconditioned Graph object to apply conditions to.
    Returns:
      a ConditionedGraph object with the same conditions as this one.

  - ### copy

    public ConditionedGraph copy()
    Copies this Graph object using the getSubGraph() method.
    Overrides:
      `copy` in class `Graph`
    Returns:
      a ConditionedGraph that is a copy of this one.

  - ### uniqueCopy

    public ConditionedGraph uniqueCopy()
    Copies this Graph producing a unique copy in which there is no entanglement between the two Graph objects. I.e. there are no shared nodes or edges between the two graphs. Mathematically speaking: `x.getNodeList().get(0) != y.getNodeList().get(0)` under any circumstances. The Nodes and Edges may remain equivalent via the equals() implementation. Further, Edge data shall remain entangled due to implementation details.
    Overrides:
      `uniqueCopy` in class `Graph`
    Returns:
      a ConditionedGraph that is a copy of this one, but with different references for its components.

  - ### toString

    public String toString()
    Description copied from class: `Graph`
    Returns a String representation of the Graph.
    Overrides:
      `toString` in class `Graph`
    Returns:
      the String representation of the Graph.