Find minimum value of edge property for all edges connected to a given node
<p>I have a network where each of my edges is labelled with a date. I want to now also label my vertices so that each vertex has a date assigned to it corresponding to the minimum date of all edges incident and emanating from it. Is there an inbuilt function to find this which would be faster than me looping over all vertices and then all edges for each vertex manually? In other words: I am after a function to find the minimum value of a given edge property for a given subset of edges.</p>

<p>My current code idea is:</p>

<pre><code>lowest_year = 2016
for v in g.vertices():
    for e in v.in_edges():
        year = g.ep.year[e]
        lowest_year = min(year,lowest_year)
    for e in v.out_edges():
        year = g.ep.year[e]
        lowest_year = min(year,lowest_year)
    g.vp.year[v]=lowest_year
    lowest_year = 2016
</code></pre>

<p>This discussion (<a href="http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Find-minimum-value-of-edge-property-for-all-edges-connected-to-a-given-node-td4026722.html" rel="nofollow">http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Find-minimum-value-of-edge-property-for-all-edges-connected-to-a-given-node-td4026722.html</a> ) contains some useful suggestions for this topic too. It also highlights that there is actually an inbuilt method in graph-tool for finding the lowest value across all outgoing, say, edges (<a href="https://graph-tool.skewed.de/static/doc/graph_tool.html#graph_tool.incident_edges_op" rel="nofollow">https://graph-tool.skewed.de/static/doc/graph_tool.html#graph_tool.incident_edges_op</a> ):</p>

<pre><code>g.vp.year = incident_edges_op(g, "out", "min", g.ep.year)
</code></pre>

<p>This would need repeating for the ingoing edges too and the minimum value between the two would then have to be found.</p>

python graph-tool