table of contents
gfx(3) | AFNIX Module | gfx(3) |
NAME¶
gfx - standard graph moduleSTANDARD GRAPH MODULE¶
The Standard Graph module is an original implementation dedicated to the graph moddeling and manipulation. At the heart of this module is the concept of edges and vertices. Graph concepts# create a default edge const edge (afnix:gfx:Edge) # create an edge with a client object const hello (afnix:gfx:Edge "hello")The edge-p predicate can be used to check for the object type. When an edge is created with client object, the get-client method can be used to access that object. Vertex construction
# create a default vertex const vrtx (afnix:gfx:Vertex) # create an vertex with a client object const world (afnix:gfx:Vertex "world")The vertex-p predicate can be used to check for the object type. When a vertex is created with a client object, the get-client method can be used to access that object. Graph construction
const graph (afnix:gfx:Graph)The add method can be used to add edges or vertices to the graph. The important point is that during the construction process, the graph structure is updated with the proper number of edge and vertices.
# create a graph const g (afnix:gfx:Graph) assert true (afnix:gfx:graph-p g) # create an edge and add vertices const edge (afnix:gfx:Edge) edge:add (afnix:gfx:Vertex "hello") edge:add (afnix:gfx:Vertex "world") assert 2 (edge:degree) # add the edge to the graph and check g:add edge assert 1 (g:number-of-edges) assert 2 (g:number-of-vertices) # check for nodes and edges assert true (afnix:gfx:edge-p (g:get-edge 0)) assert true (afnix:gfx:vertex-p (g:get-vertex 0)) assert true (afnix:gfx:vertex-p (g:get-vertex 1))
STANDARD GRAPH REFERENCE¶
Edgeedge-p
Inheritance
Object
Constructors
Edge (none)
The Edge constructor create an empty edge.
Edge (Object)
The Edge constructor create an edge with a client object.
Methods
reset -> none (none)
The reset method reset all vertices attached to the edge.
cardinality -> Integer (none)
The cardinality method returns the cardinality of the edge. The cardinality of
an edge is the number of attached vertices.
add -> Vertex (Vertex)
The add method attach a vertex to this edge. The method return the argument
vertex.
get -> Vertex (Integer)
The get method returns the attached vertex by index. If the index is out-of
range, and exception is raised.
get-client -> Object (none)
The get-client method returns the edge client object. If the client object is
not set, nil is returned.
set-client -> Object (Object)
The set-client method sets the edge client object. The object is returned by
this method.
Vertex
vertex-p
Inheritance
Object
Constructors
Vertex (none)
The Vertex constructor create an empty vertex.
Vertex (Object)
The Vertex constructor create a vertex with a client object.
Methods
reset -> none (none)
The reset method reset all edges attached to the vertex.
degree -> Integer (none)
The degree method returns the degree of the vertex. The degree of a vertex is
the number of referenced edges.
add -> Edge (Edge)
The add method references an edge with this vertex. The method return the
argument edge.
get -> Edge (Integer)
The get method returns the referenced edge by index. If the index is out-of
range, and exception is raised.
get-client -> Object (none)
The get-client method returns the vertex client object. If the client object is
not set, nil is returned.
set-client -> Object (Object)
The set-client method sets the vertex client object. The object is returned by
this method.
Graph
graph-p
Inheritance
Object
Constructors
Graph (none)
The Graph constructor create an empty graph.
Graph (Object)
The Graph constructor create a graph with a client object.
Methods
reset -> none (none)
The reset method reset the graph
reset-edges -> none (none)
The reset-edges method reset all edges attached to the graph.
reset-vertices -> none (none)
The reset-vertices method reset all vertices attached to the graph.
add -> Object (Vertex|Edge)
The add method adds a vertex or an edge to the graph. When adding an edge, the
methods check that the source and target vertices are also part of the
graph.
exists -> Boolean (Vertex|Edge)
The exists method returns true if the vertex or edge argument exists in the
graph.
get-edge -> Edge (Integer)
The get-edge method returns an edge by index. If the index is out-of-range, an
exception is raised.
get-vertex -> Vertex (Integer)
The get-vertex method returns a vertex by index. If the index is out-of-range,
an exception is raised.
number-of-vertices -> Integer (none)
The number-of-vertices methods returns the number of vertices in the
graph.
number-of-edges -> Integer (none)
The number-of-edges methods returns the number of edges in the graph.
get-client -> Object (none)
The get-client method returns the graph client object. If the client object is
not set, nil is returned.
set-client -> Object (Object)
The set-client method sets the graph client object. The object is returned by
this method.
2012-03-26 | AFNIX |