VertexDelete
does not handle edge properties properly.
g = Graph[{1 <-> 2, 2 <-> 3}, EdgeWeight -> {3.0, 4.0}];
PropertyValue[VertexDelete[g, 1], EdgeWeight]
(* {3., 4.} *)
VertexDelete[g,1]
only has one edge, yet there are two edge weight values. This is a bug.
Deleting a vertex from a weighted graph is a very basic operation that all other systems I worked with support without issue. It is a problem that comes up frequently. Why is Mathematica still struggling with basic operations like this many versions and 7 years (!) after Graph
was added?
I know that the documentation does not say that VertexDelete
works with weighted graphs, but this is a basic operation, and it should. Furthermore, the resulting graph still has an EdgeWeight
property which is no longer consistent with the EdgeList
of the graph: this is clearly a bug.
Can anyone show a robust and performant VertexDelete
implementation that can deal with weighted graphs? I prefer an implementation that works in every version between Mathematica 10.0-11.1, and which can also deal with other graph properties.