graph-list - description of graph list
A graph in Scilab is represented by a Scilab typed list. We call it a graph list.
You will find below the complete description of the list. Each element is described by one or more lines. The first line gives the name of the element and its definition. Additional informations, such as the default for elements that can have one, are given in the other lines. Indeed, only the 5 first elements must have a value in the list, all the others can be given the empty vector [] as a value, and then the default is used when it is needed by functions or by the Metanet window. For instance, you can define a graph list by
g=make_graph('min',1,1,[1],[1]);
which is the simplest graph you can create in Metanet (it is directed, has one node and one loop arc on this node).
The name of the element in the list is very important because it is used to access the elements of the list. For instance, if g is a graph list, to get the name of the graph, you only have to do:
g('name')
or
g.name
and if you want to change the name of the graph to 'toto', you have to do:
g('name')='toto';
or
g.name='toto';
Moreover, you can get the number of edges and the number of arcs of the graph by using edge_number(g) and arc_number(g) (these names do not correspond to elements of the list). For compatibility, node_number(g) can also be used instead of g('node_number') or g.node_number.
A graph list can be syntactically correct but not represent a good graph. You can use the function check_graph to check it. Moreover it is a good idea to give nodes different names. In fact, this does not give errors in Scilab, but strange behaviour can appear when using the Metanet window. This is not checked by check_graph because it is time consuming. It is only checked when loading, saving or showing a graph.
The elements of a graph list are given below:
g=load_graph(SCI+'/demos/metanet/mesh100'); g('node_color')=int(rand(1:g('node_number'))*16); g('edge_color')=int(rand(1:edge_number(g))*16); show_graph(g)