TWiki . Doc . GraphConceptsExample

// compilation unit GraphConcepts.nice
package graph;

public interface GraphEdge<Vertex> {
   Vertex source();
   Vertex target();
}

<E> Iterator<E> forIterator(Iterator<E> it) = it;

public interface VertexListGraph<Vertex, Dummy> {
   Iterator<Vertex> vertices();
   int nVertices();
}

public interface IncidenceGraph<Vertex, Edge> {
   Iterator<Edge> outEdges(Vertex v);
   int outDegree(Vertex v);
}

public interface EdgeListGraph<Vertex, Edge> {
   Iterator<Edge> edges();
}

public interface VertexListAndIncidenceGraph<Vertex, Edge> 
   extends VertexListGraph<Vertex, Edge>, IncidenceGraph<Vertex, Edge> 
{}

public interface VertexListAndIncidenceAndEdgeListGraph<Vertex, Edge> 
   extends VertexListAndIncidenceGraph<Vertex, Edge>, EdgeListGraph<Vertex, Edge>
{}

// compilation unit GeneralConcepts.nice
package graph;

// Queue concepts:
public interface Buffer<T> {
  void push(T value);
  T pop();
  boolean empty();
}

public interface MutableBuffer<T> extends Buffer<T> {
  void update(T value);
}

// Property map concepts:
public interface ReadablePropertyMap<K, V> {
  V get(K key);
}

public interface ReadWritePropertyMap<K, V> extends ReadablePropertyMap<K, V> {
  void set(K key, V value);
}

-- IsaacGouy - 07 Jan 2004

----- Revision r1.7 - 28 Apr 2005 - 11:50 GMT - TWikiGuest
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.