Class TimeLagGraph
- All Implemented Interfaces:
Graph
,TetradSerializable
,Serializable
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class represents a NodeId, which consists of the name of the node and its lag. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for TimeLagGraph.TimeLagGraph
(TimeLagGraph graph) Constructor for TimeLagGraph. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAmbiguousTriple
(Node x, Node y, Node z) addAmbiguousTriple.void
addAttribute
(String key, Object value) addAttribute.boolean
addBidirectedEdge
(Node node1, Node node2) Adds a bidirected edges <-> to the graph.boolean
addDirectedEdge
(Node node1, Node node2) Adds a directed edge --> to the graph.void
addDottedUnderlineTriple
(Node x, Node y, Node z) addDottedUnderlineTriple.boolean
Adds the specified edge to the graph, provided it is not already in the graph.boolean
Adds a node to the graph.boolean
addNondirectedEdge
(Node node1, Node node2) Adds a nondirected edges o-o to the graph.boolean
addPartiallyOrientedEdge
(Node node1, Node node2) Adds a partially oriented edge o-> to the graph.void
Adds a PropertyChangeListener to the graph.void
addUnderlineTriple
(Node x, Node y, Node z) addUnderlineTriple.boolean
addUndirectedEdge
(Node node1, Node node2) Adds an undirected edge --- to the graph.void
clear()
clear.boolean
containsEdge
(Edge edge) Determines whether this graph contains the given edge.boolean
containsNode
(Node node) Determines whether this graph contains the given node.boolean
Determines whether this graph is equal to some other graph, in the sense that they contain the same nodes and the sets of edges defined over these nodes in the two graphs are isomorphic typewise.void
fullyConnect
(Endpoint endpoint) Removes all edges from the graph and fully connects it using #-# edges, where # is the given endpoint.getAdjacentNodes
(Node node) getAdjacentNodes.getAllAttributes.Getter for the fieldambiguousTriples
.getAttribute
(String key) getAttribute.getChildren
(Node node) getChildren.int
getDegree.int
getDegree.getDirectedEdge
(Node node1, Node node2) getDirectedEdge.getDottedUnderlines.getEdge.getEdges()
getEdges.getEdges.getEdges.getEndpoint
(Node node1, Node node2) getEndpoint.int
getIndegree
(Node node) getIndegree.Getter for the fieldlag0Nodes
.int
Getter for the fieldmaxLag
.getNode.getNode.getNodeId.getNodeNames.getNodes()
getNodes.getNodesInTo
(Node node, Endpoint endpoint) Nodes adjacent to the given node with the given proximal endpoint.getNodesOutTo
(Node node, Endpoint endpoint) Nodes adjacent to the given node with the given distal endpoint.int
getNumEdges.int
getNumEdges
(Node node) getNumEdges.int
Getter for the fieldnumInitialLags
.int
getNumNodes.int
getOutdegree
(Node node) getOutdegree.getParents
(Node node) getParents.getSepset.getTimeLagGraph.getUnderLines.int
hashCode()
hashCode.boolean
isAdjacentTo
(Node node1, Node node2) isAdjacentTo.boolean
isAmbiguousTriple
(Node x, Node y, Node z) States whether r-s-r is an underline triple or not.boolean
isChildOf.boolean
isDefCollider
(Node node1, Node node2, Node node3) Added by ekorber, 2004/6/9.boolean
isDefNoncollider
(Node node1, Node node2, Node node3) Added by ekorber, 2004/6/9.boolean
isExogenous
(Node node) isExogenous.boolean
isParameterizable
(Node node) isParameterizable.boolean
isParentOf
(Node node1, Node node2) Determines whether node1 is a parent of node2.boolean
isTimeLagModel.boolean
isUnderlineTriple
(Node x, Node y, Node z) States whether r-s-r is an underline triple or not.paths()
paths.void
removeAmbiguousTriple
(Node x, Node y, Node z) removeAmbiguousTriple.void
removeAttribute
(String key) removeAttribute.void
removeDottedUnderlineTriple
(Node x, Node y, Node z) removeDottedUnderlineTriple.boolean
removeEdge
(Edge edge) Removes the given edge from the graph.boolean
removeEdge
(Node node1, Node node2) Removes the edge connecting the two given nodes, provided there is exactly one such edge.boolean
removeEdges
(Node node1, Node node2) Removes all edges connecting node A to node B.boolean
removeEdges
(Collection<Edge> edges) Iterates through the list and removes any permissible edges found.boolean
removeHighLagEdges
(int maxLag) removeHighLagEdges.boolean
removeNode
(Node node) Removes a node from the graph.boolean
removeNodes
(List<Node> nodes) Iterates through the list and removes any permissible nodes found.void
removeTriplesNotInGraph.void
removeUnderlineTriple
(Node x, Node y, Node z) removeUnderlineTriple.void
reorientAllWith
(Endpoint endpoint) Reorients all edges in the graph with the given endpoint.static TimeLagGraph
Generates a simple exemplar of this class to test serialization.void
setAmbiguousTriples
(Set<Triple> triples) setAmbiguousTriples.void
setDottedUnderLineTriples
(Set<Triple> triples) setDottedUnderLineTriples.boolean
setEndpoint
(Node from, Node to, Endpoint endPoint) Sets the endpoint type at the 'to' end of the edge from 'from' to 'to' to the given endpoint.boolean
setMaxLag
(int maxLag) Setter for the fieldmaxLag
.void
setNodes.boolean
setNumInitialLags
(int numInitialLags) Setter for the fieldnumInitialLags
.void
setUnderLineTriples
(Set<Triple> triples) setUnderLineTriples.Constructs and returns a subgraph consisting of a given subset of the nodes of this graph together with the edges between them.toString()
toString.void
transferAttributes
(Graph graph) transferAttributes.void
transferNodesAndEdges
(Graph graph) Transfers nodes and edges from one graph to another.
-
Constructor Details
-
TimeLagGraph
public TimeLagGraph()Constructor for TimeLagGraph.
-
TimeLagGraph
Constructor for TimeLagGraph.
- Parameters:
graph
- aTimeLagGraph
object
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
TimeLagGraph
object
-
addNode
Adds a node to the graph. Precondition: The proposed name of the node cannot already be used by any other node in the same graph.Nodes may be added into the getModel time step only. That is, node.getLag() must be 0.
-
removeNode
Removes a node from the graph.- Specified by:
removeNode
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- true if the node was removed, false if not.
-
addEdge
Adds the specified edge to the graph, provided it is not already in the graph. -
removeEdge
Removes the given edge from the graph.- Specified by:
removeEdge
in interfaceGraph
- Parameters:
edge
- aEdge
object- Returns:
- true if the edge was removed, false if not.
-
setMaxLag
public boolean setMaxLag(int maxLag) Setter for the field
maxLag
.- Parameters:
maxLag
- a int- Returns:
- a boolean
-
removeHighLagEdges
public boolean removeHighLagEdges(int maxLag) removeHighLagEdges.
- Parameters:
maxLag
- a int- Returns:
- a boolean
-
setNumInitialLags
public boolean setNumInitialLags(int numInitialLags) Setter for the field
numInitialLags
.- Parameters:
numInitialLags
- a int- Returns:
- a boolean
-
getNodeId
getNodeId.
- Parameters:
node
- aNode
object- Returns:
- a
TimeLagGraph.NodeId
object
-
getNode
getNode.
-
getLag0Nodes
Getter for the field
lag0Nodes
.- Returns:
- a
List
object
-
getMaxLag
public int getMaxLag()Getter for the field
maxLag
.- Returns:
- a int
-
getNumInitialLags
public int getNumInitialLags()Getter for the field
numInitialLags
.- Returns:
- a int
-
toString
toString.
-
addDirectedEdge
Adds a directed edge --> to the graph.- Specified by:
addDirectedEdge
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- a boolean
-
addUndirectedEdge
Adds an undirected edge --- to the graph.- Specified by:
addUndirectedEdge
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- a boolean
-
addNondirectedEdge
Adds a nondirected edges o-o to the graph.- Specified by:
addNondirectedEdge
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- a boolean
-
addPartiallyOrientedEdge
Adds a partially oriented edge o-> to the graph.- Specified by:
addPartiallyOrientedEdge
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- a boolean
-
addBidirectedEdge
Adds a bidirected edges <-> to the graph.- Specified by:
addBidirectedEdge
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- a boolean
-
isDefNoncollider
Added by ekorber, 2004/6/9.- Specified by:
isDefNoncollider
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
objectnode3
- aNode
object- Returns:
- true if node 2 is a definite noncollider between 1 and 3
-
isDefCollider
Added by ekorber, 2004/6/9.- Specified by:
isDefCollider
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
objectnode3
- aNode
object- Returns:
- true if node 2 is a definite collider between 1 and 3
-
getChildren
getChildren.
- Specified by:
getChildren
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- a mutable list of children for a node.
-
getDegree
public int getDegree()getDegree.
-
getEdge
getEdge.
-
getDirectedEdge
getDirectedEdge.
- Specified by:
getDirectedEdge
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- the directed edge from node1 to node2, if there is one.
-
getParents
getParents.
- Specified by:
getParents
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- the list of parents for a node.
-
getIndegree
getIndegree.
- Specified by:
getIndegree
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- the number of arrow endpoints adjacent to a node.
-
getDegree
getDegree.
-
getOutdegree
getOutdegree.
- Specified by:
getOutdegree
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- the number of null endpoints adjacent to an edge.
-
isAdjacentTo
isAdjacentTo.
- Specified by:
isAdjacentTo
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- true iff node1 is adjacent to node2 in the graph.
-
isChildOf
isChildOf.
-
isParentOf
Determines whether node1 is a parent of node2.- Specified by:
isParentOf
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- a boolean
-
transferNodesAndEdges
Transfers nodes and edges from one graph to another. One way this is used is to change graph types. One constructs a new graph based on the old graph, and this method is called to transfer the nodes and edges of the old graph to the new graph.- Specified by:
transferNodesAndEdges
in interfaceGraph
- Parameters:
graph
- the graph from which nodes and edges are to be pilfered.- Throws:
IllegalArgumentException
- This exception is thrown if adding some node.
-
transferAttributes
transferAttributes.
- Specified by:
transferAttributes
in interfaceGraph
- Parameters:
graph
- aGraph
object- Throws:
IllegalArgumentException
- if any.
-
paths
paths.
-
isParameterizable
isParameterizable.
- Specified by:
isParameterizable
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- true if the given node is parameterizable.
-
isTimeLagModel
public boolean isTimeLagModel()isTimeLagModel.
- Specified by:
isTimeLagModel
in interfaceGraph
- Returns:
- a boolean
-
getTimeLagGraph
getTimeLagGraph.
- Specified by:
getTimeLagGraph
in interfaceGraph
- Returns:
- a
TimeLagGraph
object
-
getSepset
getSepset.
-
isExogenous
isExogenous.
- Specified by:
isExogenous
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- true iff the given node is exogenous in the graph.
-
getAdjacentNodes
getAdjacentNodes.
- Specified by:
getAdjacentNodes
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- a mutable list of nodes adjacent to the given node.
-
getEndpoint
getEndpoint.
- Specified by:
getEndpoint
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- the endpoint along the edge from node to node2 at the node2 end.
-
setEndpoint
Sets the endpoint type at the 'to' end of the edge from 'from' to 'to' to the given endpoint. Note: NOT CONSTRAINT SAFE- Specified by:
setEndpoint
in interfaceGraph
- Parameters:
from
- aNode
objectto
- aNode
objectendPoint
- aEndpoint
object- Returns:
- a boolean
- Throws:
IllegalArgumentException
-
getNodesInTo
Nodes adjacent to the given node with the given proximal endpoint.- Specified by:
getNodesInTo
in interfaceGraph
- Parameters:
node
- aNode
objectendpoint
- aEndpoint
object- Returns:
- a
List
object
-
getNodesOutTo
Nodes adjacent to the given node with the given distal endpoint.- Specified by:
getNodesOutTo
in interfaceGraph
- Parameters:
node
- aNode
objectendpoint
- aEndpoint
object- Returns:
- a
List
object
-
addPropertyChangeListener
Adds a PropertyChangeListener to the graph.- Specified by:
addPropertyChangeListener
in interfaceGraph
- Parameters:
l
- aPropertyChangeListener
object
-
getEdges
getEdges.
-
containsEdge
Determines whether this graph contains the given edge.- Specified by:
containsEdge
in interfaceGraph
- Parameters:
edge
- aEdge
object- Returns:
- true iff the graph contain 'edge'.
-
containsNode
Determines whether this graph contains the given node.- Specified by:
containsNode
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- true iff the graph contains 'node'.
-
getEdges
getEdges.
-
getEdges
getEdges.
-
hashCode
public int hashCode()hashCode.
-
equals
Determines whether this graph is equal to some other graph, in the sense that they contain the same nodes and the sets of edges defined over these nodes in the two graphs are isomorphic typewise. That is, if node A and B exist in both graphs, and if there are, e.g., three edges between A and B in the first graph, two of which are directed edges and one of which is an undirected edge, then in the second graph there must also be two directed edges and one undirected edge between nodes A and B. -
fullyConnect
Removes all edges from the graph and fully connects it using #-# edges, where # is the given endpoint.- Specified by:
fullyConnect
in interfaceGraph
- Parameters:
endpoint
- aEndpoint
object
-
reorientAllWith
Reorients all edges in the graph with the given endpoint.- Specified by:
reorientAllWith
in interfaceGraph
- Parameters:
endpoint
- aEndpoint
object
-
getNode
getNode.
-
getNumNodes
public int getNumNodes()getNumNodes.
- Specified by:
getNumNodes
in interfaceGraph
- Returns:
- a int
-
getNumEdges
public int getNumEdges()getNumEdges.
- Specified by:
getNumEdges
in interfaceGraph
- Returns:
- a int
-
getNumEdges
getNumEdges.
- Specified by:
getNumEdges
in interfaceGraph
- Parameters:
node
- aNode
object- Returns:
- the number of edges in the graph which are connected to a particular node.
-
subgraph
Constructs and returns a subgraph consisting of a given subset of the nodes of this graph together with the edges between them. -
getNodes
getNodes.
-
setNodes
setNodes.
-
getNodeNames
getNodeNames.
- Specified by:
getNodeNames
in interfaceGraph
- Returns:
- a
List
object
-
clear
public void clear()clear.
-
removeEdge
Removes the edge connecting the two given nodes, provided there is exactly one such edge.- Specified by:
removeEdge
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- a boolean
-
removeEdges
Iterates through the list and removes any permissible edges found. The order in which edges are added is the order in which they are presented in the iterator.- Specified by:
removeEdges
in interfaceGraph
- Parameters:
edges
- aCollection
object- Returns:
- true if edges were added, false if not.
-
removeNodes
Iterates through the list and removes any permissible nodes found. The order in which nodes are removed is the order in which they are presented in the iterator.- Specified by:
removeNodes
in interfaceGraph
- Parameters:
nodes
- aList
object- Returns:
- true if nodes were added, false if not.
-
removeEdges
Removes all edges connecting node A to node B. In most cases, this will remove at most one edge, but since multiple edges are permitted in some graph implementations, the number will in some cases be greater than one.- Specified by:
removeEdges
in interfaceGraph
- Parameters:
node1
- aNode
objectnode2
- aNode
object- Returns:
- true if edges were removed, false if not.
-
getAllAttributes
getAllAttributes.
- Specified by:
getAllAttributes
in interfaceGraph
- Returns:
- a
Map
object
-
getAttribute
getAttribute.
- Specified by:
getAttribute
in interfaceGraph
- Parameters:
key
- aString
object- Returns:
- a
Object
object
-
removeAttribute
removeAttribute.
- Specified by:
removeAttribute
in interfaceGraph
- Parameters:
key
- aString
object
-
addAttribute
addAttribute.
- Specified by:
addAttribute
in interfaceGraph
- Parameters:
key
- aString
objectvalue
- aObject
object
-
getAmbiguousTriples
Getter for the field
ambiguousTriples
.- Specified by:
getAmbiguousTriples
in interfaceGraph
- Returns:
- a
Set
object
-
setAmbiguousTriples
setAmbiguousTriples.
- Specified by:
setAmbiguousTriples
in interfaceGraph
- Parameters:
triples
- aSet
object
-
getUnderLines
getUnderLines.
- Specified by:
getUnderLines
in interfaceGraph
- Returns:
- a
Set
object
-
getDottedUnderlines
getDottedUnderlines.
- Specified by:
getDottedUnderlines
in interfaceGraph
- Returns:
- a
Set
object
-
isAmbiguousTriple
States whether r-s-r is an underline triple or not.States whether r-s-r is an underline triple or not.
- Specified by:
isAmbiguousTriple
in interfaceGraph
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aNode
object- Returns:
- a boolean
-
isUnderlineTriple
States whether r-s-r is an underline triple or not.States whether r-s-r is an underline triple or not.
- Specified by:
isUnderlineTriple
in interfaceGraph
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aNode
object- Returns:
- a boolean
-
addAmbiguousTriple
addAmbiguousTriple.
- Specified by:
addAmbiguousTriple
in interfaceGraph
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aNode
object
-
addUnderlineTriple
addUnderlineTriple.
- Specified by:
addUnderlineTriple
in interfaceGraph
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aNode
object
-
addDottedUnderlineTriple
addDottedUnderlineTriple.
- Specified by:
addDottedUnderlineTriple
in interfaceGraph
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aNode
object
-
removeAmbiguousTriple
removeAmbiguousTriple.
- Specified by:
removeAmbiguousTriple
in interfaceGraph
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aNode
object
-
removeUnderlineTriple
removeUnderlineTriple.
- Specified by:
removeUnderlineTriple
in interfaceGraph
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aNode
object
-
removeDottedUnderlineTriple
removeDottedUnderlineTriple.
- Specified by:
removeDottedUnderlineTriple
in interfaceGraph
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aNode
object
-
setUnderLineTriples
setUnderLineTriples.
- Specified by:
setUnderLineTriples
in interfaceGraph
- Parameters:
triples
- aSet
object
-
setDottedUnderLineTriples
setDottedUnderLineTriples.
- Specified by:
setDottedUnderLineTriples
in interfaceGraph
- Parameters:
triples
- aSet
object
-
removeTriplesNotInGraph
public void removeTriplesNotInGraph()removeTriplesNotInGraph.
- Specified by:
removeTriplesNotInGraph
in interfaceGraph
-