Using EdgeMap in a script

Questions and problems about using polymake go here.

Moderator: Moderators

jrei
Posts: 15
Joined: 31 Jan 2019, 15:37

Using EdgeMap in a script

Postby jrei » 04 Mar 2019, 18:41

Dear Polymake Team,

I'm struggling with creating an EdgeMap for a directed graph in my script. Could you give me a small example on how to create and modify those objects?

Kind Regards,
JR

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

Re: Using EdgeMap in a script

Postby gawrilow » 05 Mar 2019, 00:06

Code: Select all

# this is your graph, can be created in any possible way: my $G=new common::Graph<Directed>(number_or_nodes); # this is the edge map: my $M=new EdgeMap<Directed, MyDataType>($G); # manipulate mapped values for single edges; non-existing edges are created automatically: my $value = $M->edge($from_node, $to_node); $M->edge($from_node, $to_node)=$new_value; # iterate over all existing edges and use the mapped values: for (my $edge_it=entire(edges($G)); $edge_it; ++$edge_it) { my $from_node=$edge_it->from_node; my $to_node=$edge_it->to_node; my $value=$M->[$$edge_it]; $M->[$$edge_it]=$new_value; } # the same for edges starting or ending in a given node: entire($G->out_edges($from_node)); ... entire($G->in_edges($to_node)); ...

jrei
Posts: 15
Joined: 31 Jan 2019, 15:37

Re: Using EdgeMap in a script

Postby jrei » 06 Mar 2019, 19:55

Thank you!


Return to “Helpdesk”

cron