Opened 15 years ago
Closed 15 years ago
#369 closed defect (invalid)
graphCopy crash
Reported by: | Ben Strasser | Owned by: | Peter Kovacs |
---|---|---|---|
Priority: | critical | Milestone: | LEMON 1.3 release |
Component: | core | Version: | release branch 1.1 |
Keywords: | crash graphCopy | Cc: | |
Revision id: |
Description
The following code crashes:
#include <lemon/list_graph.h> #include <lemon/core.h> #include <lemon/lgf_reader.h> typedef lemon::ListGraph Graph; using lemon::INVALID; int main(int argc, char*argv[]){ Graph g; lemon::GraphReader<Graph>(g, "bug") .run(); bool a = true; for(Graph::EdgeIt i(g); i!=INVALID;){ Graph::Edge e = i; ++i; if(a) g.erase(e); a = !a; } Graph g2; Graph::EdgeMap<Graph::Edge>edge_map(g2); lemon::graphCopy(g, g2) .edgeRef(edge_map) .run(); }
I have attached the graph in the bug file. The problem is in graphCopy because the following code works
#include <lemon/list_graph.h> #include <lemon/core.h> #include <lemon/lgf_reader.h> typedef lemon::ListGraph Graph; using lemon::INVALID; int main(int argc, char*argv[]){ Graph g; lemon::GraphReader<Graph>(g, "bug") .run(); bool a = true; for(Graph::EdgeIt i(g); i!=INVALID;){ Graph::Edge e = i; ++i; if(a) g.erase(e); a = !a; } Graph g2; Graph::EdgeMap<Graph::Edge>edge_map(g2); Graph::NodeMap<Graph::Node>node_map(g); for(Graph::NodeIt i(g); i!=INVALID; ++i){ Graph::Node u = g2.addNode(); node_map[i] = u; } for(Graph::EdgeIt i(g); i!=INVALID; ++i){ edge_map[ g2.addEdge( node_map[g.u(i)], node_map[g.v(i)] ) ] = i; } /*lemon::graphCopy(g, g2) .edgeRef(edge_map) .run();*/ }
My version is according to lemon/config.h
#define LEMON_VERSION 1.1.1
It's one of the stable releases. It's not an svn version.
Thanks for looking into this.
Attachments (1)
Change History (6)
Changed 15 years ago by
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Owner: | changed from Alpar Juttner to Peter Kovacs |
---|---|
Status: | new → assigned |
Replying to Ben:
The following code crashes:
It is not a bug, you just confused edgeRef()
and edgeCrossRef()
.
In the context of graph copying, the From->To maps are called reference maps and the To->From maps are called cross reference maps. In your second code, you create a From->To node map and a To->From edge map, i.e. a node reference map and an edge cross reference map.
Therefore, the correct usage in your first code would be:
lemon::graphCopy(g, g2) .edgeCrossRef(edge_map) .run();
This code works for me using your graph.
comment:3 Changed 15 years ago by
Replying to Ben:
My version is according to lemon/config.h
#define LEMON_VERSION 1.1.1
You may use the latest release, LEMON 1.2 (it ensures full compatibility).
comment:4 Changed 15 years ago by
I think we can close the ticket.
In similar cases, it may be a good idea to first ask the lemon-user@lemon.cs.elte.hu
mailing list, in order to check if the problem is indeed on the LEMON side.
comment:5 Changed 15 years ago by
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
If it matters my compiler flags are
CFLAGS= -g -Wall -O0 LDFLAGS=-lemon -lglpk
and its version is
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)