31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

has a source and a target. <strong>The</strong>se are objects of type gml int with path graph.edge.source<br />

and graph.edge.target, respectively. <strong>The</strong> integer values of source and target refer to node<br />

identifiers. <strong>The</strong>re are some global graph attributes, too. An object of type gml int with<br />

path graph.directed determines whether the graph is undirected (value 0) or directed<br />

(every other integer). <strong>The</strong> type of node parameters and edge parameters in parameterized<br />

graph (see manual page GRAPH) can be given by objects of type gml string<br />

with path graph.nodeT ype and graph.edgeT ype, respectively. Parameters of nodes and<br />

edges are represented by objects of type gml string with path graph.node.parameter and<br />

graph.edge.parameter, respectively.<br />

No list has to be in a specific order, e.g., you can freely mix node and edge objects in<br />

the graph list. If there are several objects in a class where just one object is required like<br />

graph.node.id, only the last such object is taken into account.<br />

Objects in classes with no predefined rules are simply ignored. This means that an<br />

application A might add specific objects to a graph description in GML format and this<br />

description is still readable for another application B which simply does not care about<br />

the objects which are specific for A.<br />

This parser supports reading user defined objects by providing a mechanism for dealing<br />

with those objects by means of callback functions. You can specify a rule for, e.g., objects<br />

with path graph.node.weight and type gml double like in the following code fragment.<br />

...<br />

bool get node weight(const gml object* gobj, graph* G, node v)<br />

{<br />

double w = gobj->get double();<br />

do something with w, the graph and the corresponding node v<br />

return true; or false if the operation failed<br />

}<br />

...<br />

main()<br />

{<br />

char* filename;<br />

...<br />

graph G;<br />

gml graph parser(G);<br />

parser.append("graph"); parser.append("node");<br />

parser.append("weight");<br />

parser.add node rule for cur path(get node weight,gml double);<br />

// or short parser.add node rule(get node weight,gml double,"weight");<br />

bool parsing ok = parser.parse(filename);<br />

...<br />

}<br />

You can add rules for the graph, for nodes, and for edges. <strong>The</strong> difference between<br />

them is the type. <strong>The</strong> type of node rules is as in the example above

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!