Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Data Science Essentials

You're reading from  Python Data Science Essentials

Product type Book
Published in Apr 2015
Publisher Packt
ISBN-13 9781785280429
Pages 258 pages
Edition 1st Edition
Languages
Toc

Graph algorithms


To get insights from graphs, many algorithms have been developed. In this chapter, we'll use a well-known graph in NetworkX, the Krackhardt Kite graph. It is a dummy graph containing 10 nodes, and it is typically used to proof graph algorithms. Krackhardt is the creator of the structure, which has the shape of a kite. It's composed of two different zones. In the first zone (composed of nodes 0 to 6), the nodes are interlinked; in the other zone (nodes 7 to 9), they are connected as a chain:

In: G = nx.krackhardt_kite_graph()
nx.draw_networkx(G)
plt.show()

Let's start with connectivity. Two nodes of a graph are connected if there is at least a path (that is, a sequence of traversed nodes) between them.

Note

Note that in a directed graph, you must follow the link's directions.

If at least a path exists, the shortest path between the two nodes is the one with the shortest collection of traversed nodes.

In NetworkX, checking whether a path exists between two nodes, calculating the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}