[Lemon-user] Question about modifying edgeMap values

Luis de la Torre ledelato at gmail.com
Tue May 10 21:39:25 CEST 2011


Hello,

I think this should be a very basic question.

I have a graph that I read in from an lgf file. A snippet of the lgf file is
here:

@edges
                label capacity
0       12       1       1
1       12       2       1
etc.

I read the graph in as is shown in the demo file

  ListGraph g;
  ListGraph::EdgeMap<int> weight(g);

  try {
    GraphReader<ListGraph>(g, "g.lgf").
      edgeMap("capacity", weight).
      run();
  } catch (Exception& error) { // check if there was any error
    std::cerr << "Error: " << error.what() << std::endl;
    return -1;
  }

Later, I'd like to modify the entries of the edgeMap weight. Specifically, I
have a complete bipartite graph with partitions A = {0,...,N-1} and B =
{N,N+1,...N+K-1}, and I want to do something like the following:

for(i = 0; i < N; i++) {
  for(k = 0; k < K; k++) {
    if(w[i][k] == 0)
      //here, change the value of edgeMap corresponding to the edge between
nodes i and k+N to zero
  }
}

How can I do this? I would like to do this by referencing the edges by their
endpoints, although I'm assuming this is impossible since this isn't a
unique identifier (I thought I saw somewhere in the documentation that it's
possible to define multiple edges between nodes). Should/can I use the
labels I defined for the edges in the .lgf file to refer to the edges? Or
what is the right way to do this?

Thank you,

Luis de la Torre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20110510/63039d78/attachment.html>


More information about the Lemon-user mailing list