Package org.cytoscape.model
Interface CyNetwork
-
- All Superinterfaces:
CyDisposable
,CyIdentifiable
- All Known Subinterfaces:
CyRootNetwork
,CySubNetwork
public interface CyNetwork extends CyIdentifiable, CyDisposable
CyNetwork is the primary interface for representing a network (graph) data structure in Cytoscape. Specifically, CyNetwork represents a multi-graph as multiple edges may exist between nodes. Edges may be directed, undirected, or both.Module:
model-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>model-api</artifactId> </dependency>
Cytoscape Backwards Compatibility (API Interface): We expect that this interface will be used but not implemented by developers using this interface. As such, we reserve the right to add methods to the interface as part of minor version upgrades. We will not remove methods for any changes other than major version upgrades.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_ATTRS
The name of the default public CyTable that is created by default for CyNetworks, CyNodes, and CyEdges.static String
HIDDEN_ATTRS
The name of the default hidden CyTable that is created by default for CyNetworks, CyNodes, and CyEdges.static String
LOCAL_ATTRS
The name of the local public CyTable that is created by default for CyNetworks, CyNodes, and CyEdges.static String
NAME
A String column created by default for every CyNetwork that holds the name of the entry.static String
SELECTED
A boolean column created by default for every CyNode or CyEdge that holds the selection state of the entry.-
Fields inherited from interface org.cytoscape.model.CyIdentifiable
SUID
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CyEdge
addEdge(CyNode source, CyNode target, boolean isDirected)
This method is used to create and add an edge to this network.CyNode
addNode()
This method is used to create and add a node to this network.boolean
containsEdge(CyEdge edge)
Determine if this CyNetwork contains a particular edge.boolean
containsEdge(CyNode from, CyNode to)
Determine if this CyNetwork contains an edge between two nodes.boolean
containsNode(CyNode node)
Determine if this CyNetwork contains a particular node.Iterable<CyEdge>
getAdjacentEdgeIterable(CyNode node, CyEdge.Type edgeType)
Gets an Iteable of edges that connect to this node.List<CyEdge>
getAdjacentEdgeList(CyNode node, CyEdge.Type edgeType)
Get the list of edges that connect to this node.List<CyEdge>
getConnectingEdgeList(CyNode source, CyNode target, CyEdge.Type edgeType)
Get the list of edges that connect two nodes.CyTable
getDefaultEdgeTable()
A convenience method returns the default attribute table for the edges of this network.CyTable
getDefaultNetworkTable()
A convenience method returns the default attribute table for this network.CyTable
getDefaultNodeTable()
A convenience method returns the default attribute table for the nodes of this network.CyEdge
getEdge(long suid)
Return the CyEdge that has the SUID.int
getEdgeCount()
Return the number of edges in this network.List<CyEdge>
getEdgeList()
Return a list of the edges in this network.List<CyNode>
getNeighborList(CyNode node, CyEdge.Type edgeType)
Get the list of nodes that neighbor this node where the definition of "neighbor" is a node that is connected to this node by the passed edgeType.CyNode
getNode(long suid)
Return the CyNode that has the SUID.int
getNodeCount()
Return the number of nodes in this network.List<CyNode>
getNodeList()
Return a list of the nodes in this network.CyRow
getRow(CyIdentifiable entry)
A convenience method that returns the row in the default table for this object.CyRow
getRow(CyIdentifiable entry, String namespace)
Returns the row for the specified table name for this object.SavePolicy
getSavePolicy()
Returns how (or if) this CyNetwork should be saved.CyTable
getTable(Class<? extends CyIdentifiable> type, String namespace)
Returns the table with the specified namespace and type from this network.boolean
removeEdges(Collection<CyEdge> edges)
Remove an edge from the network and delete the edge (if it only exists in this network).boolean
removeNodes(Collection<CyNode> node)
Remove a node from the network and delete the node (if it only exists in this network).-
Methods inherited from interface org.cytoscape.model.CyDisposable
dispose
-
Methods inherited from interface org.cytoscape.model.CyIdentifiable
getSUID
-
-
-
-
Field Detail
-
SELECTED
static final String SELECTED
A boolean column created by default for every CyNode or CyEdge that holds the selection state of the entry.- See Also:
- Constant Field Values
-
DEFAULT_ATTRS
static final String DEFAULT_ATTRS
The name of the default public CyTable that is created by default for CyNetworks, CyNodes, and CyEdges. Other CyTables may also be associated with networks -- seeCyTableManager
for more information. The table should be referenced using this constant:CyNetwork.DEFAULT_ATTRS
.- See Also:
- Constant Field Values
-
LOCAL_ATTRS
static final String LOCAL_ATTRS
The name of the local public CyTable that is created by default for CyNetworks, CyNodes, and CyEdges. This table contains attributes which are specific to only this network. -- seeCyTableManager
for more information. The table should be referenced using this constant:CyNetwork.DEFAULT_ATTRS
.- See Also:
- Constant Field Values
-
HIDDEN_ATTRS
static final String HIDDEN_ATTRS
The name of the default hidden CyTable that is created by default for CyNetworks, CyNodes, and CyEdges. Other CyTables may also be associated with networks -- seeCyTableManager
for more information.- See Also:
- Constant Field Values
-
NAME
static final String NAME
A String column created by default for every CyNetwork that holds the name of the entry.- See Also:
- Constant Field Values
-
-
Method Detail
-
addNode
CyNode addNode()
This method is used to create and add a node to this network.- Returns:
- the created node
-
removeNodes
boolean removeNodes(Collection<CyNode> node)
Remove a node from the network and delete the node (if it only exists in this network). SeeCyRootNetwork
for information about having the same node in two networks.
To delete a single node it is convenient to do it this way:network.removeNodes(Collections.singletonList(node));
- Parameters:
node
- the node to be deleted- Returns:
- true if the node was successfully deleted
-
addEdge
CyEdge addEdge(CyNode source, CyNode target, boolean isDirected)
This method is used to create and add an edge to this network.- Parameters:
source
- the source (or start) of the edgetarget
- the target (or end) of the edgeisDirected
- if 'true' this is a directed edge- Returns:
- the created edge
-
removeEdges
boolean removeEdges(Collection<CyEdge> edges)
Remove an edge from the network and delete the edge (if it only exists in this network). SeeCyRootNetwork
for information about having the same edge in two networks.
To delete a single edge it is convenient to do it this way:network.removeEdges(Collections.singletonList(edge));
- Parameters:
edges
- the edges to be deleted- Returns:
- true if the edge was successfully deleted
-
getNodeCount
int getNodeCount()
Return the number of nodes in this network.- Returns:
- the number of nodes
-
getEdgeCount
int getEdgeCount()
Return the number of edges in this network.- Returns:
- the number of edges
-
getNodeList
List<CyNode> getNodeList()
Return a list of the nodes in this network. The list will be empty if there are no nodes in the network. This method should never return null. Modifying this list (if allowed by the implementation) has no effect on the network.- Returns:
- the node list
-
getEdgeList
List<CyEdge> getEdgeList()
Return a list of the edges in this network. The list will be empty if there are no edges in the network. This method should never return null. Modifying this list (if allowed by the implementation) has no effect on the network.- Returns:
- the edge list
-
containsNode
boolean containsNode(CyNode node)
Determine if this CyNetwork contains a particular node.- Parameters:
node
- the node to check- Returns:
- true if this network contains the node
-
containsEdge
boolean containsEdge(CyEdge edge)
Determine if this CyNetwork contains a particular edge.- Parameters:
edge
- the edge to check- Returns:
- true if this network contains the edge
-
containsEdge
boolean containsEdge(CyNode from, CyNode to)
Determine if this CyNetwork contains an edge between two nodes. Note that if the edge is directed, the source and targets must match.- Parameters:
from
- the source of the edgeto
- the target of the edge- Returns:
- true if this network contains the edge
-
getNode
CyNode getNode(long suid)
Return the CyNode that has the SUID. To iterate over all nodes, iterate over getNodeList(). We make no guarantees on what represent valid values for the index. The only valid indices are those accessed from existing nodes.- Parameters:
suid
- the SUID of the CyNode to get- Returns:
- the associated CyNode or null if there is no node with that index in this network.
-
getEdge
CyEdge getEdge(long suid)
Return the CyEdge that has the SUID. To iterate over all edges, iterate over getEdgeList(). We make no guarantees on what represent valid values for the index. The only valid indices are those accessed from existing edges.- Parameters:
suid
- the SUID of the CyEdge to get- Returns:
- the associated CyEdge or null if there is no edge with that index in this network.
-
getNeighborList
List<CyNode> getNeighborList(CyNode node, CyEdge.Type edgeType)
Get the list of nodes that neighbor this node where the definition of "neighbor" is a node that is connected to this node by the passed edgeType. TheCyEdge.Type
enum is used to determine whether the list includes undirected, directed, incoming, or outgoing edges. The list will be empty if there are no neighbor nodes found. This method should never return null. Modifying this list (if allowed by the implementation) has no effect on the network. This method only returns immediate neighbors.- Parameters:
node
- the node whose neighbors we're looking foredgeType
- the directionality of the edges we're interested in- Returns:
- the list of nodes that neighbor this node
-
getAdjacentEdgeList
List<CyEdge> getAdjacentEdgeList(CyNode node, CyEdge.Type edgeType)
Get the list of edges that connect to this node. TheCyEdge.Type
enum is used to determine whether the list includes undirected, directed, incoming, or outgoing edges. The list will be empty if there are no adjacent edges found. This method should never return null. Modifying this list (if allowed by the implementation) has no effect on the network.- Parameters:
node
- the node whose edges we're looking foredgeType
- the directionality of the edges we're interested in- Returns:
- the list of edges that are adjacent to this one
-
getAdjacentEdgeIterable
Iterable<CyEdge> getAdjacentEdgeIterable(CyNode node, CyEdge.Type edgeType)
Gets an Iteable of edges that connect to this node. TheCyEdge.Type
enum is used to determine whether the list includes undirected, directed, incoming, or outgoing edges. The iterable will be empty if there are no adjacent edges found. This method should never return null. Modifying this list (if allowed by the implementation) has no effect on the network. The Iterable implementation may be more efficient because it doesn't necessarily need to create a list first. However, that depends on implementation details, so you should evaluate the method performance yourself.- Parameters:
node
- the node whose edges we're looking foredgeType
- the directionality of the edges we're interested in- Returns:
- the Iterable of edges that are adjacent to this one
-
getConnectingEdgeList
List<CyEdge> getConnectingEdgeList(CyNode source, CyNode target, CyEdge.Type edgeType)
Get the list of edges that connect two nodes. TheCyEdge.Type
enum is used to determine whether the list includes undirected, directed, incoming, or outgoing edges. The list will be empty if no connecting edges are found. This method should never return null. This method will NOT find the shortest path between two nodes that are not already immediate neighbors. Modifying this list (if allowed by the implementation) has no effect on the network.- Parameters:
source
- the source nodetarget
- the target nodeedgeType
- the directionality of the edges we're interested in- Returns:
- the list of edges that include source and target and directed edges.
-
getDefaultNetworkTable
CyTable getDefaultNetworkTable()
A convenience method returns the default attribute table for this network. This is equivalent toCyNetworkTableManager.getTableMap(this,CyNetwork.class,CyNetwork.DEFAULT_ATTRS);
- Returns:
- The default attribute table for this network.
-
getDefaultNodeTable
CyTable getDefaultNodeTable()
A convenience method returns the default attribute table for the nodes of this network. This is equivalent toCyNetworkTableManager.getTable(this,CyNode.class,CyNetwork.DEFAULT_ATTRS);
- Returns:
- The default attribute table for the nodes of this network.
-
getDefaultEdgeTable
CyTable getDefaultEdgeTable()
A convenience method returns the default attribute table for the edges of this network. This is equivalent toCyNetworkTableManager.getTableMap(this,CyEdge.class,CyNetwork.DEFAULT_ATTRS);
- Returns:
- The default attribute table for the edges of this network.
-
getTable
CyTable getTable(Class<? extends CyIdentifiable> type, String namespace)
Returns the table with the specified namespace and type from this network.- Parameters:
type
- Type ofCyIdentifiable
associated with the table.namespace
- thenamespace
the table should belong to.- Returns:
- the table with the specified namespace and type from the network.
-
getRow
CyRow getRow(CyIdentifiable entry, String namespace)
Returns the row for the specified table name for this object. A null entry or a an entry not found in this network will return null, but otherwise every node or edge in the network is guaranteed to have a row.- Parameters:
entry
- The entry (node, edge, network) whose row we're looking for.namespace
- thenamespace
of the table from which to extract the row.- Returns:
- the row in the table of the specified name for this object.
-
getRow
CyRow getRow(CyIdentifiable entry)
A convenience method that returns the row in the default table for this object. This method is equivalent to calling getCyRow(entry,DEFAULT_ATTRS
). A null entry or a an entry not found in this network will return null.- Parameters:
entry
- The entry (node, edge, network) whose row we're looking for.- Returns:
- the row in the default table for this object.
-
getSavePolicy
SavePolicy getSavePolicy()
Returns how (or if) this CyNetwork should be saved.- Returns:
- how (or if) this CyNetwork should be saved.
-
-