Source code: com/port80/graph/IVertex.java
1 //
2 // Copyright(c) 2002, Chris Leung
3 //
4
5 package com.port80.graph;
6
7 import java.io.*;
8 import java.util.*;
9 import com.port80.graph.*;
10
11 /** graph vertex interface.
12 *
13 * . Each vertex have a set of incoming edges, a set of outgoing edges
14 * and an attribute table.
15 *
16 * . Attribute registry
17 * Vertex are usually created by a VertexFactory. The
18 * VertexFactory maintain an attribute registry for the type of
19 * vertex it created. Clients that invent their own attributes
20 * should register the attribute name with the Vertex class and
21 * check for conflicts during initialization.
22 *
23 * . No checking for valid attribute name is done when accessing the
24 * attribute table for the vertex.
25 */
26 public interface IVertex extends IGraphElement {
27
28 ////////////////////////////////////////////////////////////////////////
29
30 IGraph getParent();
31 void setParent(IGraph parent);
32 void addPort(String port);
33
34 /** The set of all edges.
35 *
36 * NOTE: The set returned should be considered read only. Add or
37 * remove of edges should use method provided by the Edge class.
38 */
39 IEdge[] edges();
40 IEdge[] ins();
41 IEdge[] outs();
42
43 int inSize();
44 int outSize();
45 void addIn(IEdge e);
46 void addOut(IEdge e);
47 void addIn(IEdge e, int n);
48 void addOut(IEdge e, int n);
49 IEdge removeIn(int n);
50 IEdge removeOut(int n);
51 boolean removeIn(IEdge e);
52 boolean removeOut(IEdge e);
53 int removeInsFrom(IVertex head);
54 int removeOutsTo(IVertex head);
55
56 /**
57 * Find edge with the given attribute.
58 */
59 List findIns(String attrname, List ret);
60 List findOuts(String attrname, List ret);
61 List findEdgesTo(IVertex v, String attrname, List ret);
62 List findEdgesFrom(IVertex v, String attrname, List ret);
63
64 List findEdgesTo(IVertex v, List ret);
65 List findEdgesFrom(IVertex v, List ret);
66
67 void clearEdges();
68 void clearLayout();
69
70 /** Set of directly conected vertex.
71 *
72 * NOTE: The set returned should be considered read only. Add or
73 * remove of neighours should be done by add/remove edges.
74 *
75 */
76 Set neighbours();
77 Set reachable();
78 boolean isReachable(IVertex v);
79
80 ////////////////////////////////////////////////////////////////////////
81
82 }