Interface Graph
- All Superinterfaces:
Serializable,TetradSerializable
- All Known Implementing Classes:
Dag,EdgeListGraph,LagGraph,SemGraph,TimeLagGraph
We stipulate by extending TetradSerializable that all graphs implementing this interface are serializable. This is because for Tetrad they must be serializable. (For randomUtil, in order to be able to cancelAll operations, they must be serializable.)
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longConstantserialVersionUID=23L -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAmbiguousTriple(Node x, Node y, Node z) addAmbiguousTriple.voidaddAttribute(String key, Object value) addAttribute.booleanaddBidirectedEdge(Node node1, Node node2) Adds a bidirected edges <-> to the graph.booleanaddDirectedEdge(Node node1, Node node2) Adds a directed edge --> to the graph.voidaddDottedUnderlineTriple(Node x, Node y, Node z) addDottedUnderlineTriple.booleanAdds the specified edge to the graph, provided it is not already in the graph.booleanAdds a node to the graph.booleanaddNondirectedEdge(Node node1, Node node2) Adds a nondirected edges o-o to the graph.booleanaddPartiallyOrientedEdge(Node node1, Node node2) Adds a partially oriented edge o-> to the graph.voidAdds a PropertyChangeListener to the graph.voidaddUnderlineTriple(Node x, Node y, Node z) addUnderlineTriple.booleanaddUndirectedEdge(Node node1, Node node2) Adds an undirected edge --- to the graph.voidclear()Removes all nodes (and therefore all edges) from the graph.booleancontainsEdge(Edge edge) Determines whether this graph contains the given edge.booleancontainsNode(Node node) Determines whether this graph contains the given node.booleanDetermines 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.voidfullyConnect(Endpoint endpoint) Removes all edges from the graph and fully connects it using #-# edges, where # is the given endpoint.getAdjacentNodes(Node node) getAdjacentNodes.getAllAttributes.getAmbiguousTriples.getAttribute(String key) getAttribute.getChildren(Node node) getChildren.intgetDegree.intgetDegree.getDirectedEdge(Node node1, Node node2) getDirectedEdge.getDottedUnderlines.getEdge.getEdges()getEdges.getEdges.getEdges.getEndpoint(Node node1, Node node2) getEndpoint.intgetIndegree(Node node) getIndegree.getNode.getNodeNames.getNodes()getNodes.getNodesInTo(Node node, Endpoint n) Nodes adjacent to the given node with the given proximal endpoint.getNodesOutTo(Node node, Endpoint n) Nodes adjacent to the given node with the given distal endpoint.intgetNumEdges.intgetNumEdges(Node node) getNumEdges.intgetNumNodes.intgetOutdegree(Node node) getOutdegree.getParents(Node node) getParents.getSepset.getTimeLagGraph.getUnderLines.booleanisAdjacentTo(Node node1, Node node2) isAdjacentTo.booleanisAmbiguousTriple(Node x, Node y, Node z) States whether r-s-r is an underline triple or not.booleanisChildOf.booleanisDefCollider(Node node1, Node node2, Node node3) Added by ekorber, 2004/6/9.booleanisDefNoncollider(Node node1, Node node2, Node node3) Added by ekorber, 2004/6/9.booleanisExogenous(Node node) isExogenous.booleanisParameterizable(Node node) isParameterizable.booleanisParentOf(Node node1, Node node2) Determines whether node1 is a parent of node2.booleanisTimeLagModel.booleanisUnderlineTriple(Node x, Node y, Node z) States whether r-s-r is an underline triple or not.paths()paths.voidremoveAmbiguousTriple(Node x, Node y, Node z) removeAmbiguousTriple.voidremoveAttribute(String key) removeAttribute.voidremoveDottedUnderlineTriple(Node x, Node y, Node z) removeDottedUnderlineTriple.booleanremoveEdge(Edge edge) Removes the given edge from the graph.booleanremoveEdge(Node node1, Node node2) Removes the edge connecting the two given nodes, provided there is exactly one such edge.booleanremoveEdges(Node node1, Node node2) Removes all edges connecting node A to node B.booleanremoveEdges(Collection<Edge> edges) Iterates through the list and removes any permissible edges found.booleanremoveNode(Node node) Removes a node from the graph.booleanremoveNodes(List<Node> nodes) Iterates through the list and removes any permissible nodes found.voidremoveTriplesNotInGraph.voidremoveUnderlineTriple(Node x, Node y, Node z) removeUnderlineTriple.voidreorientAllWith(Endpoint endpoint) Reorients all edges in the graph with the given endpoint.voidsetAmbiguousTriples(Set<Triple> triples) setAmbiguousTriples.voidsetDottedUnderLineTriples(Set<Triple> triples) setDottedUnderLineTriples.booleansetEndpoint(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.voidsetNodes.voidsetUnderLineTriples(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.voidtransferAttributes(Graph graph) transferAttributes.voidtransferNodesAndEdges(Graph graph) Transfers nodes and edges from one graph to another.
-
Field Details
-
serialVersionUID
static final long serialVersionUIDConstantserialVersionUID=23L- See Also:
-
-
Method Details
-
addBidirectedEdge
Adds a bidirected edges <-> to the graph. -
addDirectedEdge
Adds a directed edge --> to the graph. -
addUndirectedEdge
Adds an undirected edge --- to the graph. -
addNondirectedEdge
Adds a nondirected edges o-o to the graph. -
addPartiallyOrientedEdge
Adds a partially oriented edge o-> to the graph. -
addEdge
Adds the specified edge to the graph, provided it is not already in the graph.- Parameters:
edge- aEdgeobject- Returns:
- true if the edge was added, false if not.
-
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.- Parameters:
node- aNodeobject- Returns:
- true if nodes were added, false if not.
-
addPropertyChangeListener
Adds a PropertyChangeListener to the graph.- Parameters:
e- aPropertyChangeListenerobject
-
clear
void clear()Removes all nodes (and therefore all edges) from the graph. -
containsEdge
Determines whether this graph contains the given edge.- Parameters:
edge- aEdgeobject- Returns:
- true iff the graph contain 'edge'.
-
containsNode
Determines whether this graph contains the given node.- Parameters:
node- aNodeobject- Returns:
- true iff the graph contains 'node'.
-
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.- Parameters:
endpoint- aEndpointobject
-
reorientAllWith
Reorients all edges in the graph with the given endpoint.- Parameters:
endpoint- aEndpointobject
-
getAdjacentNodes
getAdjacentNodes.
- Parameters:
node- aNodeobject- Returns:
- a mutable list of nodes adjacent to the given node.
-
getChildren
getChildren.
- Parameters:
node- aNodeobject- Returns:
- a mutable list of children for a node.
-
getDegree
int getDegree()getDegree.
- Returns:
- the connectivity of the graph.
-
getEdge
getEdge.
- Parameters:
node1- aNodeobjectnode2- aNodeobject- Returns:
- the edge connecting node1 and node2, provided a unique such edge exists.
- Throws:
UnsupportedOperationException- if the graph allows multiple edges between node pairs.
-
getDirectedEdge
getDirectedEdge.
- Parameters:
node1- aNodeobjectnode2- aNodeobject- Returns:
- the directed edge from node1 to node2, if there is one.
- Throws:
UnsupportedOperationException- if the graph allows multiple edges between node pairs.
-
getEdges
getEdges.
- Parameters:
node- aNodeobject- Returns:
- the list of edges connected to a particular node. No particular ordering of the edges in the list is guaranteed.
-
getEdges
getEdges.
-
getEdges
getEdges.
- Returns:
- the set of edges in the graph. No particular ordering of the edges in the list is guaranteed.
-
getEndpoint
getEndpoint.
-
getIndegree
getIndegree.
- Parameters:
node- aNodeobject- Returns:
- the number of arrow endpoints adjacent to a node.
-
getDegree
getDegree.
- Parameters:
node- aNodeobject- Returns:
- the number of arrow endpoints adjacent to a node.
-
getNode
getNode.
- Parameters:
name- aStringobject- Returns:
- the node with the given string name. In case of accidental duplicates, the first node encountered with the given name is returned. In case no node exists with the given name, null is returned.
-
getNodes
getNodes.
- Returns:
- the list of nodes for the graph.
-
setNodes
setNodes.
- Parameters:
nodes- aListobject
-
getNodeNames
getNodeNames.
- Returns:
- the names of the nodes, in the order of
getNodes.
-
getNumEdges
int getNumEdges()getNumEdges.
- Returns:
- the number of edges in the (entire) graph.
-
getNumEdges
getNumEdges.
- Parameters:
node- aNodeobject- Returns:
- the number of edges in the graph which are connected to a particular node.
-
getNumNodes
int getNumNodes()getNumNodes.
- Returns:
- the number of nodes in the graph.
-
getOutdegree
getOutdegree.
- Parameters:
node- aNodeobject- Returns:
- the number of null endpoints adjacent to an edge.
-
getParents
getParents.
- Parameters:
node- aNodeobject- Returns:
- the list of parents for a node.
-
isAdjacentTo
isAdjacentTo.
-
isChildOf
isChildOf.
-
isParentOf
Determines whether node1 is a parent of node2. -
isDefNoncollider
Added by ekorber, 2004/6/9. -
isDefCollider
Added by ekorber, 2004/6/9. -
isExogenous
isExogenous.
- Parameters:
node- aNodeobject- Returns:
- true iff the given node is exogenous in the graph.
-
getNodesInTo
Nodes adjacent to the given node with the given proximal endpoint. -
getNodesOutTo
Nodes adjacent to the given node with the given distal endpoint. -
removeEdge
Removes the given edge from the graph.- Parameters:
edge- aEdgeobject- Returns:
- true if the edge was removed, false if not.
-
removeEdge
Removes the edge connecting the two given nodes, provided there is exactly one such edge.- Parameters:
node1- aNodeobjectnode2- aNodeobject- Returns:
- a boolean
- Throws:
UnsupportedOperationException- if multiple edges between node pairs are not supported.
-
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. -
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.- Parameters:
edges- aCollectionobject- Returns:
- true if edges were added, false if not.
-
removeNode
Removes a node from the graph.- Parameters:
node- aNodeobject- Returns:
- true if the node was removed, 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.- Parameters:
nodes- aListobject- Returns:
- true if nodes were added, false if not.
-
setEndpoint
Sets the endpoint type at the 'to' end of the edge from 'from' to 'to' to the given endpoint. Note: NOT CONSTRAINT SAFE -
subgraph
Constructs and returns a subgraph consisting of a given subset of the nodes of this graph together with the edges between them. -
toString
String toString()toString.
-
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.- 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.
- Parameters:
graph- aGraphobject- Throws:
IllegalArgumentException- if any.
-
paths
Paths paths()paths.
- Returns:
- a
Pathsobject
-
isParameterizable
isParameterizable.
- Parameters:
node- aNodeobject- Returns:
- true if the given node is parameterizable.
-
isTimeLagModel
boolean isTimeLagModel()isTimeLagModel.
- Returns:
- true if this is a time lag model, in which case getTimeLagGraph() returns the graph.
-
getTimeLagGraph
TimeLagGraph getTimeLagGraph()getTimeLagGraph.
- Returns:
- the underlying time lag model, if there is one; otherwise, returns null.
-
getSepset
getSepset.
-
getAllAttributes
getAllAttributes.
- Returns:
- a
Mapobject
-
getAttribute
getAttribute.
-
removeAttribute
removeAttribute.
- Parameters:
key- aStringobject
-
addAttribute
addAttribute.
-
getUnderLines
getUnderLines.
- Returns:
- a
Setobject
-
getDottedUnderlines
getDottedUnderlines.
- Returns:
- a
Setobject
-
getAmbiguousTriples
getAmbiguousTriples.
- Returns:
- a
Setobject
-
setAmbiguousTriples
setAmbiguousTriples.
- Parameters:
triples- aSetobject
-
isAmbiguousTriple
States whether r-s-r is an underline triple or not. -
isUnderlineTriple
States whether r-s-r is an underline triple or not. -
addAmbiguousTriple
addAmbiguousTriple.
-
addUnderlineTriple
addUnderlineTriple.
-
addDottedUnderlineTriple
addDottedUnderlineTriple.
-
removeAmbiguousTriple
removeAmbiguousTriple.
-
removeUnderlineTriple
removeUnderlineTriple.
-
removeDottedUnderlineTriple
removeDottedUnderlineTriple.
-
setUnderLineTriples
setUnderLineTriples.
- Parameters:
triples- aSetobject
-
setDottedUnderLineTriples
setDottedUnderLineTriples.
- Parameters:
triples- aSetobject
-
removeTriplesNotInGraph
void removeTriplesNotInGraph()removeTriplesNotInGraph.
-