Package edu.cmu.tetrad.graph
Class ReplicatingGraph
java.lang.Object
edu.cmu.tetrad.graph.EdgeListGraph
edu.cmu.tetrad.graph.ReplicatingGraph
- All Implemented Interfaces:
Graph,TripleClassifier,TetradSerializable,Serializable
EdgeListGraph subclass that applies an
EdgeReplicationPolicy whenever edges are added/removed or endpoints
are oriented.
Only the mutating operations are overridden; everything else uses the standard EdgeListGraph behavior.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty repeating graph using the given policy.ReplicatingGraph(Graph g, EdgeReplicationPolicy policy) Creates a newReplicatingGraphby copying the structure and attributes from the provided graph and applying the specified edge replication policy.Copies nodes+edges from g and installs the policy.ReplicatingGraph(List<Node> nodes, EdgeReplicationPolicy policy) Constructs a new ReplicatingGraph using the provided list of nodes and edge replication policy. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds an edge to the graph and performs additional processing to mirror edges based on the defined edge replication policy.Retrieves the current edge replication policy for the graph.booleanremoveEdge(Edge e) Removes an edge from the graph, and if applicable, removes its mirrored counterparts according to the edge replication policy.booleanremoveEdge(Node a, Node b) Removes an edge between the specified nodes, if such an edge exists in the graph.voidReorients all applicable edges in the graph to align with the specified endpoint.booleansetEndpoint(Node from, Node to, Endpoint ep) Mirrors endpoint changes across all policy-mirrored edges.static ReplicatingGraphsvar()Creates a new instance ofReplicatingGraphusing a defaultLagReplicationPolicy.static ReplicatingGraphConstructs a ReplicatingGraph using the given list of nodes and applies a default LagReplicationPolicy for edge replication.Methods inherited from class edu.cmu.tetrad.graph.EdgeListGraph
addAmbiguousTriple, addAttribute, addBidirectedEdge, addDirectedEdge, addDottedUnderlineTriple, addNode, addNondirectedEdge, addPartiallyOrientedEdge, addPropertyChangeListener, addUnderlineTriple, addUndirectedEdge, changeName, clear, containsEdge, containsNode, equals, existsSemidirectedPath, fullyConnect, getAdjacentNodes, getAllAttributes, getAmbiguousTriples, getAncillaryGraph, getAttribute, getChildren, getDegree, getDegree, getDirectedEdge, getDottedUnderlines, getEdge, getEdges, getEdges, getEdges, getEndpoint, getIndegree, getNode, getNodeNames, getNodes, getNodesInTo, getNodesOutTo, getNumEdges, getNumEdges, getNumNodes, getOutdegree, getParents, getSepset, getSepset, getSepsetContaining, getTimeLagGraph, getTriplesClassificationTypes, getTriplesLists, getUnderLines, hashCode, isAdjacentTo, isAmbiguousTriple, isAncestorOf, isChildOf, isDefCollider, isDefNoncollider, isExogenous, isMSeparatedFrom, isParameterizable, isParentOf, isTimeLagModel, isUnderlineTriple, paths, removeAmbiguousTriple, removeAttribute, removeDottedUnderlineTriple, removeEdges, removeEdges, removeNode, removeNodes, removeTriplesNotInGraph, removeUnderlineTriple, serializableInstance, setAmbiguousTriples, setAncillaryGraph, setDottedUnderLineTriples, setNodes, setUnderLineTriples, subgraph, toString, transferAttributes, transferNodesAndEdges
-
Constructor Details
-
ReplicatingGraph
Creates an empty repeating graph using the given policy.- Parameters:
policy- The policy.
-
ReplicatingGraph
Copies nodes+edges from g and installs the policy.- Parameters:
g- the graph to copy.
-
ReplicatingGraph
Creates a newReplicatingGraphby copying the structure and attributes from the provided graph and applying the specified edge replication policy.- Parameters:
g- the original graph to be replicated; must not be nullpolicy- the edge replication policy to apply to the new graph; must not be null
-
ReplicatingGraph
Constructs a new ReplicatingGraph using the provided list of nodes and edge replication policy.- Parameters:
nodes- the list of nodes to initialize the graph withpolicy- the edge replication policy to be applied in the graph; must not be null
-
-
Method Details
-
svar
Constructs a ReplicatingGraph using the given list of nodes and applies a default LagReplicationPolicy for edge replication.- Parameters:
nodes- the list of nodes to initialize the graph with; must not be null- Returns:
- a new instance of ReplicatingGraph with the provided nodes and a default edge replication policy
-
svar
Creates a new instance ofReplicatingGraphusing a defaultLagReplicationPolicy.- Returns:
- a new
ReplicatingGraphinstance with the defaultLagReplicationPolicy.
-
addEdge
Adds an edge to the graph and performs additional processing to mirror edges based on the defined edge replication policy.- Specified by:
addEdgein interfaceGraph- Overrides:
addEdgein classEdgeListGraph- Parameters:
e- the edge to be added to the graph; must not be null- Returns:
- true if the graph was modified as a result of this operation, false otherwise
- Throws:
IllegalArgumentException- if the provided edge is invalid or does not meet the requirements
-
removeEdge
Removes an edge from the graph, and if applicable, removes its mirrored counterparts according to the edge replication policy.- Specified by:
removeEdgein interfaceGraph- Overrides:
removeEdgein classEdgeListGraph- Parameters:
e- the edge to be removed; must not be null- Returns:
- true if the graph was modified as a result of this operation, false otherwise
-
removeEdge
Removes an edge between the specified nodes, if such an edge exists in the graph. This operation is synchronized to ensure thread safety.- Specified by:
removeEdgein interfaceGraph- Overrides:
removeEdgein classEdgeListGraph- Parameters:
a- the first node of the edgeb- the second node of the edge- Returns:
- true if the edge was successfully removed and the graph was modified, false otherwise
-
setEndpoint
Mirrors endpoint changes across all policy-mirrored edges. This keeps algorithms that orient by setEndpoint() fully SVAR-aware without needing a custom endpoint strategy.- Specified by:
setEndpointin interfaceGraph- Overrides:
setEndpointin classEdgeListGraph- Parameters:
from- the node from which the edge originatesto- the node to which the edge pointsep- aEndpointobject- Returns:
- true if the endpoint was successfully set and the graph was modified, false otherwise
- Throws:
IllegalArgumentException
-
reorientAllWith
Reorients all applicable edges in the graph to align with the specified endpoint. This method leverages the superclass implementation to perform the reorientation and ensures that any custom mirroring behavior required by this class is preserved.- Specified by:
reorientAllWithin interfaceGraph- Overrides:
reorientAllWithin classEdgeListGraph- Parameters:
ep- the endpoint configuration to apply to all applicable edges; must not be null
-
getReplicationPolicy
Retrieves the current edge replication policy for the graph.- Returns:
- the
EdgeReplicationPolicyused by the graph for determining how edges should be mirrored and synchronized.
-