next up previous contents index
Next: 1.2.3 Adjacency lists Up: 1.2 Various representations of Previous: 1.2.1 Names and numbers

1.2.2 Tail head

We have seen that the standard representation of a graph used by Metanet is by the means of two row vectors tail and head: arc number i goes from node number tail(i) to node number head(i). The size of these vectors is the same and is the number of arcs of the graph.

Moreover the number of nodes must be given. It is greater than or equal to the maximum integer number in tail and head. If node numbers do not belong to tail and head then there are isolated nodes.

If the graph is undirected, it is the same, but tail(i) and head(i) can be exchanged.

This representation is very general and gives directed or undirected multigraphs with possible loops and isolated nodes.

The standard function to create graphs is make_graph (see 2.1). For instance, we can create a small directed graph with a loop and an isolated node (see figure 1) by using:
node number = 4, tail = [1,1,2,3], head = [2,3,1,3],
or in Scilab:
g=make_graph('foo',1,4,[1 1 2 3],[2 3 1 3]);


  
Figure 1: Small directed graph
\begin{figure}\begin{center}%
\begin{picture}
(0,0)%
\epsfig{file=foo.pstex} %
\...
...p %
\begin{picture}
(2281,1486)(753,-787)
\end{picture}\end{center} \end{figure}


next up previous contents index
Next: 1.2.3 Adjacency lists Up: 1.2 Various representations of Previous: 1.2.1 Names and numbers
Scilab Group