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 and Description
    --- | ---
    `private java.util.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 and Description
    --- | ---
    `private` | `ConditionedGraph(Graph graph, java.util.Collection<Condition> conditions)` Private constructor used to create copies of ConditionedGraph objects.
    `` | `ConditionedGraph(java.lang.String graphName)` Public constructor for creating a simple ConditionedGraph.
    `` | `ConditionedGraph(java.lang.String graphName, java.util.Collection<Condition> conditions)` Public constructor for creating a ConditionedGraph.
    `` | `ConditionedGraph(java.lang.String graphName, java.util.Collection<Condition> conditions, boolean forceOnAdd)` Public constructor for creating a ConditionedGraph.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCondition(Condition condition)` Adds a condition to the graph.
    `boolean` | `addPartialGraph(java.util.List<Node> nodes, java.util.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.
    `java.util.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(java.util.List<Node> nodes, java.util.List<Edge> edges)` Private method for circumventing the condition restrictions.
    `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, getAdjacencyList, getEdge, getEdge, getEdge, getEdgeList, getName, getNodeCount, getNodeIndex, getNodeIndex, getNodeList, getNodeName, getSubGraph, getSubGraph, getSubGraph, transpose, transpose, transpose`

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

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

- - ### Field Detail

    - #### conditions

          private final java.util.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 Detail

    - #### ConditionedGraph

          public ConditionedGraph(java.lang.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(java.lang.String graphName,
                                  java.util.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(java.lang.String graphName,
                                  java.util.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,
                                   java.util.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 Detail

    - #### 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 java.util.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(java.util.List<Node> nodes,
                                         java.util.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(java.util.List<Node> nodes,
                                            java.util.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.