Finding cliques (I)
You're now going to practice finding cliques in G. Recall that cliques are "groups of nodes that are fully connected to one another", while a maximal clique is a clique that cannot be extended by adding another node in the graph.
本练习是课程的一部分
Introduction to Network Analysis in Python
练习说明
- Count the number of maximal cliques present in the graph and print it.
- Use the
nx.find_cliques()function ofGto find the maximal cliques. - The
nx.find_cliques()function returns a generator object. To count the number of maximal cliques, you need to first convert it to a list withlist()and then use thelen()function. Place this inside aprint()function to print it.
- Use the
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Calculate the maximal cliques in G: cliques
cliques = ____
# Count and print the number of maximal cliques in G
print(____)