gfx ‐ standard graph module The Standard Graphmodule is an original implementationdedicated to the graph moddeling and manipulation. At theheart of this module is the concept of edges and vertices.Graphconcepts The afnix‐gfxmodule provides the support for manipulating graphs. Formally a graph is a collection of edges and vertices. In a normal graph, an edge connects two vertices. On the other hand, a vertex can have several edges. When an edge connects several vertices, it is called an hyperedge and the resulting structure is called an hypergraph.Edgeclass The Edgeclass is a class used for a graph construction in association with the Vertexclass. An edge is used to connect vertices. Normally, an edge connects two vertices. The number of vertices attached to an edge is called the cardinality of that edge. When the edge cardinality is one, the edge is called a self‐loop. This mean that the edge connects the vertex to itself. This last point is merely a definition but present the advantage of defining an hyperedge as a set of vertices.Vertexclass The Vertexis the other class used for the graph construction. and operates with the edgeclass. A vertex is used to reference edges. the number of edges referenced by a vertex is called the degree of that vertex.GraphThe Graphclass is class that represent either a graph or a hypergraph. By definition, a graph is collection of edges and vertices. There are numerous property attached to graph. Formally, a graph consists of a set of edges, a set of vertices and the associated endpoints. However, the implementation is designed in a way so that each edge and vertex carry its associated objects. This method ensures that the graph is fully defined by only its two sets.Graphconstruction The graph construction is quite simple and proceed by adding edges and vertices. The base system does not enforce rules on the graph structure. it is possible to add con connected vertices as well as unreferenced edges.Edgeconstruction An edge is constructed by simply invoking the default constructor. Optionally, a client object can be attached to the edge. # create a default edge const edge (afnix:gfx:Edge) ‐2‐ # create an edge with a client object const hello (afnix:gfx:Edge "hello") The edge‐ppredicate can be used to check for the object type. When an edge is created with client object, the get‐ clientmethod can be used to access that object.Vertexconstruction A vertex is constructed a way similar to the Edge>object. The vertex is constructed by simply invoking the default constructor. Optionally, a client object can be attached to the edge. # create a default vertex const vrtx (afnix:gfx:Vertex) # create an vertex with a client object const world (afnix:gfx:Vertex "world") The vertex‐ppredicate can be used to check for the object type. When a vertex is created with a client object, the get‐clientmethod can be used to access that object.Graphconstruction A graph is constructed by simply adding edges and vertices to it. The graph‐ppredicate can be use to assert the graph type. the graph class also supports the concept of client object which can be attached at construction or with the set‐clientmethod. const graph (afnix:gfx:Graph) The addmethod 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)) ‐3‐EdgeThe Edgeclass is a class used for a graph construction in association with the Vertexclass. An edge is used to connect vertices. Normally, an edge connects two vertices. The number of vertices attached to an edge is called the cardinality of that edge. A client object can also be attached to the class.Predicateedge‐pInheritanceObjectConstructorsEdge(none) The Edgeconstructor create an empty edge.Edge(Object) The Edgeconstructor create an edge with a client object.Methodsnonereset‐> The resetmethod reset all vertices attached to the edge. Integercardinality‐> The cardinalitymethod returns the cardinality of the edge. The cardinality of an edge is the number of attached vertices. Vertexadd‐> The addmethod attach a vertex to this edge. The method return the argument vertex. Vertexget‐> The getmethod returns the attached vertex by index. If the index is out‐of range, and exception is raised. Objectget‐client‐> The get‐clientmethod returns the edge client object. If the client object is not set, nil is returned. Objectset‐client‐> The set‐clientmethod sets the edge client object. The object is returned by this method. ‐4‐VertexThe Vertexclass is a class used for a graph construction in association with the Edgeclass. An vertex is an edge node. The number of edges referenced by a vertex is called the degree of that vertex. A client object can also be attached to the object.Predicatevertex‐pInheritanceObjectConstructorsVertex(none) The Vertexconstructor create an empty vertex.Vertex(Object) The Vertexconstructor create a vertex with a client object.Methodsnonereset‐> The resetmethod reset all edges attached to the vertex. Integerdegree‐> The degreemethod returns the degree of the vertex. The degree of a vertex is the number of referenced edges. Edgeadd‐> The addmethod references an edge with this vertex. The method return the argument edge. Edgeget‐> The getmethod returns the referenced edge by index. If the index is out‐of range, and exception is raised. Objectget‐client‐> The get‐clientmethod returns the vertex client object. If the client object is not set, nil is returned. Objectset‐client‐> The set‐clientmethod sets the vertex client object. The object is returned by this method.GraphThe Graphobject is a general graph class that manages a set of edges and vertices. The graph operates by adding edges and vertices to it. The graph object also accepts a client object in a way similar to the Edgeand Vertexclasses ‐5‐Predicategraph‐pInheritanceObjectConstructorsGraph(none) The Graphconstructor create an empty graph.Graph(Object) The Graphconstructor create a graph with a client object.Methodsnonereset‐> The resetmethod reset the graph nonereset‐edges‐> The reset‐edgesmethod reset all edges attached to the graph. nonereset‐vertices‐> The reset‐verticesmethod reset all vertices attached to the graph. Objectadd‐> The addmethod 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. Booleanexists‐> The existsmethod returns true if the vertex or edge argument exists in the graph. Edgeget‐edge‐> The get‐edgemethod returns an edge by index. If the index is out‐of‐range, an exception is raised. Vertexget‐vertex‐> The get‐vertexmethod returns a vertex by index. If the index is out‐of‐range, an exception is raised. Integernumber‐of‐vertices‐> The number‐of‐verticesmethods returns the number of vertices in the graph. Integernumber‐of‐edges‐> The number‐of‐edgesmethods returns the number of edges in the graph. ‐6‐ Objectget‐client‐> The get‐clientmethod returns the graph client object. If the client object is not set, nil is returned. Objectset‐client‐> The set‐clientmethod sets the graph client object. The object is returned by this method.