Hi everyone,
Does anyone have a way to use the find_edge() function to match edges based on whether the parameter property contains a value as opposed to a complete match? E.g., whether edges contain '2008' as opposed to something like 'Thu May 15 06:07:27 UTC 2008'. I looked at the source code in the latest git version, and it looks I'm limited to a direct match (for strings), but I wonder if anyone has any suggestions for how we can improve this code to match based on a substring? Could be handy.
Thanks!
-- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
Hi,
On 10/14/2012 01:36 AM, mstcamus wrote:
Hi everyone,
Does anyone have a way to use the find_edge() function to match edges based on whether the parameter property contains a value as opposed to a complete match? E.g., whether edges contain '2008' as opposed to something like 'Thu May 15 06:07:27 UTC 2008'. I looked at the source code in the latest git version, and it looks I'm limited to a direct match (for strings), but I wonder if anyone has any suggestions for how we can improve this code to match based on a substring? Could be handy.
The find_edge/vertex() functions have a limited functionality, which is meant to improve the performance of the typical case of finding a particular vertex/edge. For more complicated cases, one can usually whip up an equivalent python expression which would do the trick... For instance, what you are suggesting can performed with:
edges = [e for e in g.edges() if "2008" in prop[e]]
Cheers, Tiago