The maximum independent set isn’t displayed correctly
Code (source : networkx):
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from networkx.algorithms import approximation as approx
G = nx.Graph(
[
(1, 2),
(1, 3),
(3, 2),
(5, 2),
(3, 4),
(6, 4),
(6, 5),
(3, 5),
(5, 4),
(7, 4),
(1, 7),
]
)
I = approx.maximum_independent_set(G)
print(f”Maximum independent set of G: {I}”)
pos = nx.spring_layout(G, seed=3929879)
nx.draw(
G,
pos=pos,
with_labels=True,
node_color=[“tab:red” if n in I else “tab:blue” for n in G],
)
Here is the final result
So I tried to find the maximal independent set in a graph (I used networkx’s program) but the node number 6 isn’t recognized in the set. Is there a reason why, and is it linked to the core program?
Pancak.1609 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.