How can i make K7,2 graph and how can i delete 2 vertex? Btw, i need to use package -> Combinatorica`;
I tried this:
a = CompleteGraph[7, 2]
DeleteVertex[a, {3, 4}]
ShowGraph[a]
but it doesn't work ..
Thanks,
Needs["Combinatorica`"]
a = CompleteGraph[7, 2];
An alternative, more convenient, Combinatorica
function is DeleteVertices
, which takes a list of vertices to be deleted.
The function DeleteVertex
takes a single vertex as the second
argument, not a list of vertices. Thus, If you have to use DeleteVertex
, you need to use Fold
: delete
vertex 3
in graph a
, and, then delete vertex 3
in the resulting
graph (which is vertex 4
in the original graph). Alternatively, you can sort the list of vertices-to-be-deleted in descending order in the third argument of Fold
.
b1 = DeleteVertices[a, {3, 4}];
b2 = Fold[DeleteVertex, a, {3, 3}];
(* or b2 = Fold[DeleteVertex, a, {4, 3}]; *)
Row[{ShowGraph[a, VertexStyle -> Disk[.05], VertexColor -> Green,
VertexLabel -> (Style[#, 18] & /@ Range[9]), ImageSize -> 300],
ShowGraph[b1, VertexStyle -> Disk[.05], VertexColor -> Green,
VertexLabel -> (Style[#, 18] & /@ Drop[Range[9], {3, 4}]), ImageSize -> 300],
ShowGraph[b2, VertexStyle -> Disk[.05], VertexColor -> Green,
VertexLabel -> (Style[#, 18] & /@ Drop[Range[9], {3, 4}]), ImageSize -> 300]}]
"Combinatorica`"
functionsDeleteVertex
andShowGraph
. If it is, then it is not a duplicate of the linked Q/As. Angel, please clarify if you need to use the functionDeleteVertex
(hence, the packageCombinatorica
package) or either of the linked Q/As gives the answer you need. $\endgroup$Combinatorica
functionDeleteVertex
. $\endgroup$