Boost logo

Boost Users :

Subject: Re: [Boost-users] graph
From: Cedric Laczny (cedric.laczny_at_[hidden])
Date: 2011-02-09 11:33:06


On Wednesday, 9. February 2011 16:58:21 Soso F wrote:
> please could someone tell me how can i read from file using BGL. the data
> in a file will be the graph component.
> I don,t want to use graphviz, any other way?
>
> thanks
>
>

As Nicholas Mario Wardhana pointed out in the eMail you just answered to, this
depends on the input file.
You may have several different layouts possible so you should either provide an
example-layout so that one might help you quick or, even better, write the
parser on your own. Because after all that's also part of the work, I assume.
An example layout might be:

v1<tab>v2
v2<tab>v3
v1<tab>v2

which is not based on the layout imposed by graphviz.
Your data may also originate from a table and might actually represent an
adjacency matrix. However, no one can know this if you don't provide more and,
especially, helpful information.

You might want to use boost::split() to split up your lines and use
std::getline() to read in a file line-by-line. Maybe there are more
sophisticated solutions using Boost, like a tokenizer or such.

Best,

Cedric

>
>
>
> ________________________________
> From: Nicholas Mario Wardhana <mario.wardhana_at_[hidden]>
> To: boost-users_at_[hidden]
> Sent: Tue, February 8, 2011 8:32:24 PM
> Subject: Re: [Boost-users] graph
>
> On 9 February 2011 05:22, Soso F <soso_ss2211_at_[hidden]> wrote:
> > Hello,
> >
> > I'm using BGL to build a graph which represents a network. I'm wondering
> > if I can read a file to be the input " vertices , edges and weight"
> > without using graphviz.
> >
> > Thx
>
> Hi,
>
> I think your problem is independent from BGL. Once you can parse the
> file and get the data correctly, you can make them the attributes of
> your vertices, edges, and weights. You can simply use STL or any other
> library.
>
> Best regards,
> Nicholas Mario Wardhana
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net