org.gicentre.utils.network
Class Edge

java.lang.Object
  extended by org.gicentre.utils.network.Edge

public class Edge
extends java.lang.Object

Represents an edge between two nodes in a network graph structure. This class has a default drawing behaviour, but by inheriting it and overriding its draw() method, visual appearance of the edge can be customised.

Version:
3.3, 1st August, 2011.
Author:
Jo Wood, giCentre, City University London.

Constructor Summary
Edge(Node n1, Node n2)
          Creates an undirected edge between the given nodes.
Edge(Node n1, Node n2, boolean isDirected)
          Creates a possibly directed edge between the given nodes.
 
Method Summary
 void draw(processing.core.PApplet applet, float p1x, float p1y, float p2x, float p2y)
          Allows the edge to be drawn in the given Processing applet.
 Node getNode1()
          Reports the first node connected to this edge
 Node getNode2()
          Reports the second node connected to this edge
 boolean isDirected()
          Reports whether or not this edge is directed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Edge

public Edge(Node n1,
            Node n2)
Creates an undirected edge between the given nodes.

Parameters:
n1 - First node in the edge.
n2 - Second node in the edge.

Edge

public Edge(Node n1,
            Node n2,
            boolean isDirected)
Creates a possibly directed edge between the given nodes.

Parameters:
n1 - First node in the edge.
n2 - Second node in the edge.
isDirected - If true the edge runs from n1 to n2 but not the other way. If false, the edge represents an undirected connection between the two nodes.
Method Detail

draw

public void draw(processing.core.PApplet applet,
                 float p1x,
                 float p1y,
                 float p2x,
                 float p2y)
Allows the edge to be drawn in the given Processing applet.

Parameters:
applet - Processing sketch in which to draw this edge.
p1x - x-coordinate of the first node in the edge.
p1y - y-coordinate of the first node in the edge.
p2x - x-coordinate of the second node in the edge.
p2y - y-coordinate of the second node in the edge.

getNode1

public Node getNode1()
Reports the first node connected to this edge

Returns:
First node connected to this edge.

getNode2

public Node getNode2()
Reports the second node connected to this edge

Returns:
Second node connected to this edge.

isDirected

public boolean isDirected()
Reports whether or not this edge is directed.

Returns:
True if this edge is directed (from node1 to node2).


giCentre Utilities V.3.3, API documentation generated 6th April, 2013