Creating a graph with edge properties

Questions and problems about using polymake go here.
xammy
Posts: 9
Joined: 07 Mar 2011, 17:32

Creating a graph with edge properties

Postby xammy » 26 Mar 2012, 10:28

Hi,

I known how to create a new graph object visible in perl using the following code.

Code: Select all

perl::Object construct_graph(...) { Graph<> g(4); g.edge(0, 1); g.edge(1, 2); g.edge(2, 0); g.edge(0, 3); perl::Object result("graph::Graph<Undirected>"); result.take("ADJACENCY") << g; return result; }
How do I add edge properties (ints in my case) to it? If there are several ways - I'd like to have one such that it is easy to display these ints in a $graph->VISUAL; call.

Does graph::Graph allow parallel edges and loops?

Best regards,

Matthias

herr
Developer
Posts: 40
Joined: 30 Dec 2010, 13:15

Re: Creating a graph with edge properties

Postby herr » 26 Mar 2012, 11:02

How do I add edge properties (ints in my case) to it?
It should be possible to add properties to edges by using an EdgeMap, e.g. see polymake/apps/graph/src/edge_lengths.cc.

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: Creating a graph with edge properties

Postby gawrilow » 26 Mar 2012, 15:30

I'd like to have one such that it is easy to display these ints in a $graph->VISUAL; call.
The EdgeMaps (as well as NodeMaps) are not automatically involved in the visualization process. You'll have to find some way to make the values from the map visible, e.g. by using them as EdgeLabels or invent some color scheme based on them.
Does graph::Graph allow parallel edges and loops?
Loops are allowed, but not parallel edges.

User avatar
joswig
Main Author
Posts: 282
Joined: 24 Dec 2010, 11:10

Re: Creating a graph with edge properties

Postby joswig » 27 Mar 2012, 09:47

You'll have to find some way to make the values from the map visible, e.g. by using them as EdgeLabels or invent some color scheme based on them.
Actually, this will also depend on the visualization backend's capabilities. I am not sure if JReality and JavaView support edge labels at all.

xammy
Posts: 9
Joined: 07 Mar 2011, 17:32

Re: Creating a graph with edge properties

Postby xammy » 28 Mar 2012, 16:58

Does graph::Graph allow parallel edges and loops?
Loops are allowed, but not parallel edges.
Then I have a problem indeed - without parallel edges not all matroid decompositions for the TU test extension may be displayed correctly.

User avatar
joswig
Main Author
Posts: 282
Joined: 24 Dec 2010, 11:10

Re: Creating a graph with edge properties

Postby joswig » 28 Mar 2012, 19:00

Multigraphs do not exits in polymake yet. But they could be modeled as graphs of type props::graph with edge attributes of type int (to count the number of parallel edges). To avoid ambiguity one should probably restrict those attributes to positive integers.

In case that later anyone even needs edge attributes for multigraphs these could be modeled as one Array per edge (representing a parallel class of multiedges).

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: Creating a graph with edge properties

Postby gawrilow » 16 Apr 2012, 01:19

Now multigraphs are implemented; please use the type Graph<DirectedMulti> or Graph<UndirectedMulti> depending on your needs (and, naturally, the same tag for EdgeMaps and other attribute maps attached to your graph). Please refer to the rulefile apps/common/rules/graph_types to get acquainted with new methods introduced for multigraphs.

As the implementation is quite fresh, it could still contain bugs undiscovered by unit tests; please feel free to report any problems or shortcomings immediately.

xammy
Posts: 9
Joined: 07 Mar 2011, 17:32

Re: Creating a graph with edge properties

Postby xammy » 16 Apr 2012, 08:18

Now multigraphs are implemented; ...
Very nice - I will start working on them as soon as I'm done with lots of other things! Thank you for the effort.


Return to “Helpdesk”