Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uchicago.src.sim.network
Class DefaultNode

    java.lang.Object
      uchicago.src.sim.network.DefaultNode

All Implemented Interfaces:
  Node

Direct Known Subclasses:
  DefaultDrawableNode

    public class DefaultNode

extends java.lang.Object
implements Node

A simple graph node that is a default implementation of Node.

Version:
  $Revision: 1.15 $ $Date: 2004/11/03 19:51:01 $
Author:
  Nick Collier
See Also:
  `Node`, `Edge`

Nested Class Summary
`protected static class` | `DefaultNode.OrderedHashMap` HashMap that keeps an ordered list of its keys.

Field Summary
`protected java.util.ArrayList` | `inEdges` A list of the edges into this Node.
`protected DefaultNode.OrderedHashMap` | `inMap` A Map of nodes whose edges are into this Node.
`protected java.lang.String` | `label`
`protected java.util.ArrayList` | `outEdges` A list of the edges out of this Node.
`protected DefaultNode.OrderedHashMap` | `outMap` A Map of nodes whose edges are out of this Node.

Constructor Summary
`DefaultNode()` Creates a DefaultNode with a blank label.
`DefaultNode(java.lang.String label)` Creates a DefaultNode with the specified string as its label.

Method Summary
`void` | `addInEdge(Edge edge)` Adds an in Edge to this DefaultNode.
`void` | `addInEdges(java.util.Collection edges)` Adds in edges.
`void` | `addOutEdge(Edge edge)` Adds an out Edge to this DefaultNode
`void` | `addOutEdges(java.util.Collection edges)` Adds out edges.
`void` | `clearInEdges()` Clears (removes) all the in edges.
`void` | `clearOutEdges()` Clears (removes) all the out edges.
`java.util.HashSet` | `getEdgesFrom(Node node)` Returns the Edges from the specified Node to this Node.
`java.util.HashSet` | `getEdgesTo(Node node)` Returns the Edges from this Node to the specified Node.
`java.util.ArrayList` | `getFromNodes()` Gets all of the Nodes that this DefaultNode has an edge from.
`java.lang.Object` | `getId()` Gets a unique id for this node.
`int` | `getInDegree()` Gets the in degree of this DefaultNode.
`java.util.ArrayList` | `getInEdges()` Gets the ArrayList of edges into this node.
`java.util.ArrayList` | `getInNodes()` Gets all of the Nodes that this DefaultNode has an edge from.
`Node` | `getNode()` Deprecated. No longer part of the Node interface so not necessary
`java.lang.String` | `getNodeLabel()` Gets the label for this node.
`int` | `getNumInEdges()` Returns the number of in edges contained by the Node.
`int` | `getNumOutEdges()` Returns the number of out edges contained by the Node.
`int` | `getOutDegree()` Gets the out degree of this DefaultNode.
`java.util.ArrayList` | `getOutEdges()` Gets the ArrayList of Edge out of this node.
`java.util.ArrayList` | `getOutNodes()` Gets all of the Nodes that this DefaultNode has an edge to.
`Node` | `getRandomFromNode()` Gets a node at random from the list of nodes that this node has an edge from.
`Node` | `getRandomNodeIn()` Gets a node at random from the list of in edges.
`Node` | `getRandomNodeOut()` Gets a node at random from the list of out edges.
`Node` | `getRandomToNode()` Gets a node at random from the list of nodes that this node has an edge to.
`java.util.ArrayList` | `getToNodes()` Gets all of the Nodes that this DefaultNode has an edge to.
`boolean` | `hasEdgeFrom(Node node)` Returns true if this DefaultNode has an Edge from the specified Node, otherwise false.
`boolean` | `hasEdgeTo(Node node)` Returns true if this DefaultNode has an Edge to the specified Node, otherwise false.
`boolean` | `hasEdgeToOrFrom(Node node)` Does this Node have an edge to or from the specified node.
`Edge` | `makeRandomInEdge(java.util.List list, Edge edge, boolean allowSelfLoops)` Creates an in edge to this node from a randomly chosen node in the specified list using the specified edge.
`Edge` | `makeRandomOutEdge(java.util.List list, Edge edge, boolean allowSelfLoops)` Creates an out edge from this node to a randomly chosen node in the specified list using the specified edge.
`void` | `removeEdgesFrom(Node node)` Removes all the edges that link to this Node from the specified node.
`void` | `removeEdgesTo(Node node)` Removes all the edges that link from this Node to the specified node.
`void` | `removeInEdge(Edge edge)` Removes the specified edge from the list of "in" edges.
`void` | `removeOutEdge(Edge edge)` Removes the specified edge from the list of "out" edges.
`void` | `setNodeLabel(java.lang.String label)` Sets the label for this node.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### inEdges

    protected java.util.ArrayList inEdges

  A list of the edges into this Node.

### inMap

    protected DefaultNode.OrderedHashMap inMap

  A Map of nodes whose edges are into this Node. The Node is the key and a HashSet of edges is the value.

### outEdges

    protected java.util.ArrayList outEdges

  A list of the edges out of this Node.

### outMap

    protected DefaultNode.OrderedHashMap outMap

  A Map of nodes whose edges are out of this Node. The Node is the key and a Hashset of edges is the value.

### label

    protected java.lang.String label

Constructor Detail

### DefaultNode

    public DefaultNode()

  Creates a DefaultNode with a blank label.

### DefaultNode

    public DefaultNode(java.lang.String label)

  Creates a DefaultNode with the specified string as its label.

  Parameters:
    `label` - the label for this node

Method Detail

### getId

    public java.lang.Object getId()

  Gets a unique id for this node. This returns the hashCode as an Integer.

  Specified by:
    `getId` in interface `Node`

### getNodeLabel

    public java.lang.String getNodeLabel()

  Gets the label for this node.

  Specified by:
    `getNodeLabel` in interface `Node`

### setNodeLabel

    public void setNodeLabel(java.lang.String label)

  Sets the label for this node.

  Specified by:
    `setNodeLabel` in interface `Node`

### getInEdges

    public java.util.ArrayList getInEdges()

  Gets the ArrayList of edges into this node. The order of the list is the order in which the Edges where added.

  Specified by:
    `getInEdges` in interface `Node`

### getOutEdges

    public java.util.ArrayList getOutEdges()

  Gets the ArrayList of Edge out of this node. The order of the list is the order in which the Edges where added.

  Specified by:
    `getOutEdges` in interface `Node`

### getFromNodes

    public java.util.ArrayList getFromNodes()

  Gets all of the Nodes that this DefaultNode has an edge from. This is a list of all the nodes on the end of this node's in edges.

### getToNodes

    public java.util.ArrayList getToNodes()

  Gets all of the Nodes that this DefaultNode has an edge to. This is a list of all the nodes on the end of this node's out edges.

### getOutNodes

    public java.util.ArrayList getOutNodes()

  Gets all of the Nodes that this DefaultNode has an edge to. This is a list of all the nodes on the end of this node's out edges. The iteration order of these Nodes will be the order in which the corresponding edges were first added to this DefaultNode.

### getInNodes

    public java.util.ArrayList getInNodes()

  Gets all of the Nodes that this DefaultNode has an edge from. This is a list of all the nodes on the end of this node's in edges. The iteration order of these Nodes will be the order in which the corresponding edges were first added to this DefaultNode.

### hasEdgeToOrFrom

    public boolean hasEdgeToOrFrom(Node node)

  Does this Node have an edge to or from the specified node.

  Parameters:
    `node` - the node to check if this DefaultNode contains an edge to.

### addInEdge

    public void addInEdge(Edge edge)

  Adds an in Edge to this DefaultNode.

  Specified by:
    `addInEdge` in interface `Node`
  Parameters:
    `edge` - the "in" edge to add

### addOutEdge

    public void addOutEdge(Edge edge)

  Adds an out Edge to this DefaultNode

  Specified by:
    `addOutEdge` in interface `Node`
  Parameters:
    `edge` - the "out" edge to add

### addOutEdges

    public void addOutEdges(java.util.Collection edges)

  Adds out edges.

### addInEdges

    public void addInEdges(java.util.Collection edges)

  Adds in edges.

### clearInEdges

    public void clearInEdges()

  Clears (removes) all the in edges.

  Specified by:
    `clearInEdges` in interface `Node`

### clearOutEdges

    public void clearOutEdges()

  Clears (removes) all the out edges. This does not NOT remove these cleared out edges as in edges from the Nodes on the other side of these edges.

  Specified by:
    `clearOutEdges` in interface `Node`

### removeInEdge

    public void removeInEdge(Edge edge)

  Removes the specified edge from the list of "in" edges. This does NOT remove the edge as an out edge from the Node on the other side of this Edge. This does not NOT remove these cleared in edges as out edges from the Nodes on the other side of these edges.

  Specified by:
    `removeInEdge` in interface `Node`
  Parameters:
    `edge` - the edge to remove

### removeOutEdge

    public void removeOutEdge(Edge edge)

  Removes the specified edge from the list of "out" edges. This does NOT remove the edge as an in edge from the Node on the other side of this Edge.

  Specified by:
    `removeOutEdge` in interface `Node`
  Parameters:
    `edge` - the edge to remove

### getNode

    public Node getNode()

  Deprecated. No longer part of the Node interface so not necessary

  Returns the actual Node associated with this Node. This is for those Nodes that wrap other Nodes, such as OvalNode and RectNode which are primiarily drawable wrappers around Nodes. All network operations, adding edges etc., should be done to the Node returned by this method. DefaultNode merely returns itself.

### getRandomNodeOut

    public Node getRandomNodeOut()

  Gets a node at random from the list of out edges. This will return null if there are no out edges.

### getRandomNodeIn

    public Node getRandomNodeIn()

  Gets a node at random from the list of in edges. This will return null if there are no in edges.

### getRandomFromNode

    public Node getRandomFromNode()

  Gets a node at random from the list of nodes that this node has an edge from. This is identical to getRandomNodeIn().

### getRandomToNode

    public Node getRandomToNode()

  Gets a node at random from the list of nodes that this node has an edge to. This is identical to getRandomNodeOut().

### removeEdgesTo

    public void removeEdgesTo(Node node)

  Removes all the edges that link from this Node to the specified node. This does NOT remove these edges as from edges from the specified node.

### removeEdgesFrom

    public void removeEdgesFrom(Node node)

  Removes all the edges that link to this Node from the specified node. This does NOT remove these edges as to edges from the specified node.

### makeRandomOutEdge

    public Edge makeRandomOutEdge(java.util.List list,
                                  Edge edge,
                                  boolean allowSelfLoops)

  Creates an out edge from this node to a randomly chosen node in the specified list using the specified edge. If allowSelfLoops is true, then the created Edge may return a self loop, assuming that this Node is an element in the list. If not, then the returned Edge will always be to some other Node. Note that this method adds the edge as an in edge to the random node, and as an out edge to this DefaultNode.

  Parameters:
    `list` - the list of nodes to create the Edge to.
    `edge` - the edge to use as the link
    `allowSelfLoops` - if true then self loops are allowed. If not the self loops are disallowed.

### makeRandomInEdge

    public Edge makeRandomInEdge(java.util.List list,
                                 Edge edge,
                                 boolean allowSelfLoops)

  Creates an in edge to this node from a randomly chosen node in the specified list using the specified edge. If allowSelfLoops is true, then the created Edge may return a self loop, assuming that this Node is an element in the list. If not, then the returned Edge will always be to some other Node. Note that this method adds the edge as an out edge to the random node, and as an in edge to this DefaultNode.

  Parameters:
    `list` - the list of nodes to create the Edge from.
    `edge` - the edge to use as the link
    `allowSelfLoops` - if true then self loops are allowed. If not the self loops are disallowed.

### getNumOutEdges

    public int getNumOutEdges()

  Returns the number of out edges contained by the Node.

### getNumInEdges

    public int getNumInEdges()

  Returns the number of in edges contained by the Node.

### hasEdgeTo

    public boolean hasEdgeTo(Node node)

  Returns true if this DefaultNode has an Edge to the specified Node, otherwise false.

  Specified by:
    `hasEdgeTo` in interface `Node`

### hasEdgeFrom

    public boolean hasEdgeFrom(Node node)

  Returns true if this DefaultNode has an Edge from the specified Node, otherwise false.

  Specified by:
    `hasEdgeFrom` in interface `Node`

### getOutDegree

    public int getOutDegree()

  Gets the out degree of this DefaultNode. Same as getNumOutEdges().

### getInDegree

    public int getInDegree()

  Gets the in degree of this DefaultNode. Same as getNumInEdges().

### getEdgesTo

    public java.util.HashSet getEdgesTo(Node node)

  Returns the Edges from this Node to the specified Node. This will return null if no such Edges exist.

### getEdgesFrom

    public java.util.HashSet getEdgesFrom(Node node)

  Returns the Edges from the specified Node to this Node. This will return null if no such Edges exits.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD