In reply to: " edge function"
Hi stephan,
sorry about the lack of detail in my question.
Below you can find the code for a network factory class. The code
reads a file (like this)
300
0 37 0 1 2 3 4 5 6 8 9 15 17 21 42 44 51 56 63 66 77 84 86 93 123
126 128 129 151 153 163 164 170 219 225 240 247 261 288 290
1 12 0 0 2 11 18 33 47 66 95 127 192 209 211
2 51 0 1 0 3 5 6 7 8 10 12 13 14 15 16 17 19 25 27 31 35 36 38 49
78 79 81 84 88 91 93 104 111 139 156 169 175 178 188 203 208 223 227
243 247 249 253 255 266 267 268 282 286
3 8 0 2 0 4 29 42 55 62 257
4 11 0 3 0 18 34 52 59 108 139 216 235 296
5 14 0 2 0 26 50 56 58 71 74 80 186 191 193 194 283
6 14 0 0 2 7 16 30 34 46 57 101 141 174 198 215 291
7 6 0 2 6 67 82 97 181
...
and when the member function 'create' is called, the network should
be returned.
The error was a runtime error. I got the following answer from Xcode:
[Session started at 2006-09-19 09:57:00 +0200.]
#seed.in not found. Creating a new seed...
seed = 583597
gamenetwork has exited due to signal 10 (SIGBUS).
I examined your code and adapted mine to yours and noticed that the
error disappears
when I change
g=new Graph();
to
g=new Graph(1);
in the member function parseFile. It seems that this is the error
that I made (as I expected it is a silly one). Could you tell me why
the '1' is required here?
Thanks for the help
Tom
==networkfact.h
#ifndef __NETWORKFACTORY_H
#define __NETWORKFACTORY_H
#include "factory.h"
#include
Hi Tom,
2006/9/19, Tom Lenaerts
Hi stephan, [snip]
I examined your code and adapted mine to yours and noticed that the error disappears when I change g=new Graph(); to g=new Graph(1); in the member function parseFile. It seems that this is the error that I made (as I expected it is a silly one). Could you tell me why the '1' is required here?
Quoting from ajacency-list docs:
adjacency_list(vertices_size_type n, const GraphProperty& p = GraphProperty()) Creates a graph object with n vertices and zero edges.
You've just missed to add vertices to the graph. The call Graph(1) creates an adjacency_list with one vertex (which was enough for my example). Maybe you want to create a graph with "numnodes", which you read from the beginning of your file. Additionally you may want to have a look at the add_edge(..) documentation, too. As it describes why your program worked with just one vertex added in the beginning. (The others were created through add_edge, if the first edge(...) call didn't fail, I think). Cheers, Stephan btw: check http://www.boost.org/libs/tokenizer/index.html
participants (2)
-
Stephan Diederich
-
Tom Lenaerts