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 Details

    • 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:
    • 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 -- see CyTableManager for more information. The table should be referenced using this constant: CyNetwork.DEFAULT_ATTRS.
      See Also:
    • 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. -- see CyTableManager for more information. The table should be referenced using this constant: CyNetwork.DEFAULT_ATTRS.
      See Also:
    • 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 -- see CyTableManager for more information.
      See Also:
    • NAME

      static final String NAME
      A String column created by default for every CyNetwork that holds the name of the entry.
      See Also:
  • Method Details

    • 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). See CyRootNetwork 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 edge
      target - the target (or end) of the edge
      isDirected - 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). See CyRootNetwork 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 edge
      to - 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. The CyEdge.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 for
      edgeType - 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. The CyEdge.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 for
      edgeType - 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. The CyEdge.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 for
      edgeType - 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. The CyEdge.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 node
      target - the target node
      edgeType - 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 to CyNetworkTableManager.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 to CyNetworkTableManager.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 to CyNetworkTableManager.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 of CyIdentifiable associated with the table.
      namespace - the namespace 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 - the namespace 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.