2
$\begingroup$

Given the following directed graph, is there a way to delete all edges that contain a specified vertex label name. For instance, suppose the edge list below was read in. Any edge in that list with a vertex labeled by x would be deleted, along with the vertices on both sides of that edge. For example, in the edge list below, the graph would be generated for just the edges N4 -> N5, N6 -> N2, N6 -> N3, N6 -> N4, N1 -> N8, N2 -> N8, N4 -> N8, N7 -> N8, N9 -> N7, N9 -> N8

edges = {N1 -> x, x -> N3, x -> x, N4 -> N5, N6 -> N2, N6 -> N3, N6 -> N4, N1 -> N8, N2 -> N8, N4 -> N8, N7 -> N8, N9 -> N7, N9 -> N8} g = Graph[edges, VertexLabels -> Automatic] 
$\endgroup$

1 Answer 1

2
$\begingroup$

You can use VertexDelete[g,v] to delete vertex $v$ and all edges connected to $v$.

VertexDelete[g, x] 

enter image description here

$\endgroup$
1
  • $\begingroup$ Oh, yes; of course!! ... Many thanks kglr!! $\endgroup$ Commented May 17, 2023 at 2:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.