igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] C/igraph: How to handle weighted graphs?


From: Tamas Nepusz
Subject: Re: [igraph] C/igraph: How to handle weighted graphs?
Date: Tue, 1 Sep 2015 15:00:28 +0200

> What is the proper way to handle weighted graphs with C/igraph?
Either store them in a separate vector and pass that as an argument,
or store them as attributes and extract the attribute vector if needed
(before passing it as an argument).

> It appears that most (all?) functions that use weights take the
> weights as a separate argument (and ignore them if passed NULL).
Yes, exactly.

> Is there any reason, other than perhaps convenience, why I should store
> the weights as a graph attribute instead of a separate vector?
If you pass the graph along as an argument between some of your
functions, you would need to pass the attribute vectors as well if you
don't store the attributes using the attribute handler interface.

> Do any functions automatically use the weights stored in the graph itself?
No, all functions that take weights accept them in a separate vector.
This makes it possible to run the same function with different weight
vectors without having to store them as part of the graph.

> I am working on an igraph interface for Mathematica.  I am asking this
> question to make sure the choice I make will work well with all
> functions, including the ones I haven't looked at yet.
Higher level interfaces usually establish some convention for handling
weights; for instance, the Python interface keeps the "weight=..."
argument of the C interface and assumes that it has a null value by
default. However, the Python interface accepts Python lists as well as
attribute names for the argument.

T.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]