Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/port80/graph/IGraph.java


1   //
2   // Copyright(c) 2002, Chris Leung
3   //
4   
5   package com.port80.graph;
6   
7   import java.util.Collection;
8   import java.util.List;
9   import java.util.Set;
10  
11  import com.port80.util.attr.IAttrTable;
12  
13  /** Graph interface.
14   *
15   *  . Each Graph have a name, a set of vertex (and thus a set of edges
16   *    that come with it) and graph, and an attribute table. Each graph
17   *    also have an associated vertex and edge factory.  The default
18   *    vertex factory would only allow vertex with unique names.  The
19   *    default edge factory is DefaultEdgeFactory which allow any kind
20   *    of edges.
21   *
22   *  . Graph is a container of GraphElement including Graph instances
23   *    themselves.  A graph can be viewed in two perspectives.  Vertex
24   *    and Edge are connected in a flat heirarchy.  However, the graph
25   *    can also be viewed as a tree of graphs each containing a set of
26   *    vertices.
27   *
28   *  . Attribute registry
29   *    The edge class has an associated registry to register the
30   *    valid attribute names for the class.  Clients that invent
31   *    their own attributes should register the attribute name with the
32   *    class and check for conflicts during initialization.
33   *  . No checking for valid attribute name is done when accessing the
34   *    attribute table.
35   *
36   *  HISTORY
37   *
38   *  v1.1 2002-03-07
39   *  . Adding subgraph support.
40   *
41   */
42  public interface IGraph extends IGraphElement {
43  
44    ////////////////////////////////////////////////////////////////////////
45  
46    IVertexFactory getVertexFactory();
47    IEdgeFactory getEdgeFactory();
48    IAttrTable getVertexAttrTable();
49    IAttrTable getEdgeAttrTable();
50  
51    boolean isCluster();
52  
53    IGraph newGraph(String name,Object data);
54    IVertex newVertex(String name, Object data) throws GraphException;
55    IVertex newVertex(String name, String port, Object data) throws GraphException;
56    IEdge newEdge(IVertex tail, IVertex head, String name, Object data) throws GraphException;
57    void addVertex(IVertex v) throws GraphException;
58    void addAllVertex(Collection c) throws GraphException;
59    /** Remove vertex from this graph, not include vertex in subgraph .*/
60    IVertex removeVertex(String name);
61    IVertex removeVertex(IVertex v);
62    boolean removeEdge(IEdge e);
63    boolean isValid(IVertex head, IVertex tail);
64    boolean canDelete(IEdge e);
65  
66    String getGraphTypeName();
67    IGraph getParent();
68    //void setParent(IGraph parent);
69    boolean containsVertex(String name);
70    boolean containsVertex(IVertex v);
71    IVertex getVertex(String name);
72    IVertex getVertex(IVertex v);
73    /** Vertices name/vertices in this graph, not including those in subgraph. */
74    Set getVertexNameSet();
75    Set getVertexSet();
76    /** Edges in this graph, not including those in subgraph. */
77    Set getEdgeSet();
78    /*
79    boolean removeAllVertex(Collection c);
80    boolean clear();
81    */
82    /** Vertices including those in subgraph. */
83    Set allVertexNameSet();
84    Set allVertices();
85    Set allEdges();
86    int size();
87    void clearLayout();
88  
89    List getSubGraphs();
90    IGraph getGraph(IGraph g);
91    boolean containsGraph(IGraph g);
92    //boolean addGraph(IGraph g);
93    //boolean removeGraph(IGraph g);
94  
95    Set findVerticesWithAttr(String attrname);
96    Set findEdgesWithAttr(String attrname);
97    
98    String sprintGraph();
99    boolean saveImage(String filename, float scale);
100 
101   ////////////////////////////////////////////////////////////////////////
102 
103 }