net.sf.myra.framework
Class Graph<V extends Info>

java.lang.Object
  extended by net.sf.myra.framework.Graph<V>

public class Graph<V extends Info>
extends java.lang.Object

This class represents the problem construction graph. Note that this implementation is not synchronized.

Version:
$Revision$ $Date:: $
Author:
Fernando Esteban Barril Otero

Nested Class Summary
static class Graph.EdgeEvaporateTransform
          This class represents the probabilistic evaporation transform.
static class Graph.EdgeInitializationTransform
          This class represents an initialization transform.
static class Graph.EdgeRangeTransform
          This class represents the range-fixed pheromone transform.
static class Graph.Element
          This class represents an element of the graph.
 
Field Summary
static net.sf.myra.framework.Graph.Transform EDGE_EVAPORATION
          The edge pheromone normalization transformation.
static net.sf.myra.framework.Graph.Transform EDGE_INITIALIZATION
          The edge pheromone initialisation transformation.
 
Constructor Summary
Graph()
          Default constructor.
Graph(int capacity)
          Creates a new Graph instance with the specified initial capacity.
 
Method Summary
 void add(Vertex<V> vertex)
          Adds a new node to the graph.
 void apply(net.sf.myra.framework.Graph.Transform transform)
          Applies the specified tranformation in this graph.
 void connect()
          Fully connects all nodes of the graph.
 void connect(Vertex<V> from, Vertex<V> to)
          Creates an edge (link) between the specified nodes.
 Vertex<V> get(java.lang.String label)
          Returns the specified vertex given its label.
 Edge<V> getEdge(Vertex<V> from, Vertex<V> to)
          Returns the edge between the specified vertices.
 java.util.Collection<Edge<V>> getEdges(Vertex<V> vertex)
          Returns the list of edges of the specified vertex.
 java.util.Collection<Vertex<V>> getNeighbours(Vertex<V> vertex)
          Returns the list of neighbors of the specified node.
 java.util.Collection<Vertex<V>> getVertices()
          Returns the set of vertices of this graph.
 void merge(Graph<V> other)
          Merges the specified graph with this graph, by adding an edge from every vertex on this graph to every vertex of the specified graph.
 java.lang.String toString()
           
 Vertex<V>[] vertices()
          Returns the array of vertices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EDGE_EVAPORATION

public static final net.sf.myra.framework.Graph.Transform EDGE_EVAPORATION
The edge pheromone normalization transformation.


EDGE_INITIALIZATION

public static final net.sf.myra.framework.Graph.Transform EDGE_INITIALIZATION
The edge pheromone initialisation transformation.

Constructor Detail

Graph

public Graph()
Default constructor.


Graph

public Graph(int capacity)
Creates a new Graph instance with the specified initial capacity.

Parameters:
capacity - the initial capacity.
Method Detail

add

public void add(Vertex<V> vertex)
Adds a new node to the graph.

Parameters:
vertex - the node to add.

apply

public void apply(net.sf.myra.framework.Graph.Transform transform)
Applies the specified tranformation in this graph.

Parameters:
transform - the transformation to be applied.

connect

public void connect(Vertex<V> from,
                    Vertex<V> to)
Creates an edge (link) between the specified nodes.

Parameters:
from - the start node.
to - the end node.

connect

public void connect()
Fully connects all nodes of the graph.


merge

public void merge(Graph<V> other)
Merges the specified graph with this graph, by adding an edge from every vertex on this graph to every vertex of the specified graph.

Parameters:
other - the graph to be merged.

getNeighbours

public java.util.Collection<Vertex<V>> getNeighbours(Vertex<V> vertex)
Returns the list of neighbors of the specified node.

Parameters:
vertex - the node in the graph.
Returns:
the list of neighbors of the node.

getEdges

public java.util.Collection<Edge<V>> getEdges(Vertex<V> vertex)
Returns the list of edges of the specified vertex.

Parameters:
vertex - the node in the graph.
Returns:
the list of edges of the vertex.

getEdge

public Edge<V> getEdge(Vertex<V> from,
                       Vertex<V> to)
Returns the edge between the specified vertices.

Parameters:
from - the "from" end of the edge.
to - the "to" end of the edge.
Returns:
the edge between the specified vertices.

get

public Vertex<V> get(java.lang.String label)
Returns the specified vertex given its label.

Parameters:
label - the label of the vertex.
Returns:
the specified vertex given its label.

getVertices

public java.util.Collection<Vertex<V>> getVertices()
Returns the set of vertices of this graph.

Returns:
the set of vertices of this graph.

vertices

public Vertex<V>[] vertices()
Returns the array of vertices. Note that the array may have null position if the initial capacity is greater than the number of vertices.

Returns:
the array of vertices.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2013. All Rights Reserved.