title: Add new vertex if edge attribute is greater than some value
body: <p>I want to insert a new vertex if an edge attribute is greater than some value and then split the edge attribute, for example:</p>
  
  <pre><code>library(igraph)
  m &lt;- matrix(c(1:5,2:6), nc = 2, byrow = F)
  g &lt;- graph_from_edgelist(m)
  g &lt;- set_edge_attr(g, name = "dists", value = c(5,8,10, 15, 7))
  plot(g, edge.arrow.size = 0)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Vlv3F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vlv3F.png" alt="enter image description here"></a></p>
  
  <p>I want to add a new vertex if the edge attribute "dists" is > 10, for this graph that is between the 3rd and 4th vertices as the edge attribute is 15.</p>
  
  <pre><code>E(g)$dists
  [1]  5  8 10 15  7
  
  # psuedo code of what I want to do
  for(i in E(g)) {
    if (E(g)$dists[i] &gt; 10) {
      #add new node and split the edge weights
    }
  }
  </code></pre>
  
  <p>what the result would look like</p>
  
  <pre><code>m2 &lt;- matrix(c(1:6,2:7), nc = 2, byrow = F)
  g2 &lt;- graph_from_edgelist(m2)
  g2 &lt;- set_edge_attr(g2, name = "dists", value = c(10,10,10, 7.5, 7.5, 10))
  plot(g2, edge.arrow.size = 0)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JkIYL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JkIYL.png" alt="enter image description here"></a></p>
  
  <p>A new vertex has been added between the old 3rd and 4th vertices and the edge attribute that was 15 has been split to 7.5 and 7.5, across the new edges.  </p>
  
  <pre><code>E(g2)$dists
  [1] 10.0 10.0 10.0  7.5  7.5 10.0
  </code></pre>
  
  <p>This a toy example, in my data there are 100's of vertices and 10's of new vertices will be getting added, so I can't do it manually. Any help much appreciated. </p>