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 loading, dumping, and sampling


Beyond NetworkX, graphs and networks can be generated and analyzed with other software. One of the best open source multi-platform software that can be used for their analysis is named Gephi. It's a visual tool and it doesn't require programming skills. It's freely available at http://gephi.github.io.

As in machine learning datasets, even graphs have standard formats for their storing, loading, and exchanging. In this way, you can create a graph with NetworkX, dump it to a file, and then load and analyze it with Gephi.

One of the most frequently used formats is Graph Modeling Language (GML). Now, let's see how to dump a graph to GML file:

In:
dump_file_base = "dumped_graph"
# Be sure the dump_file file doesn't exist
def remove_file(filename):
    import os
    if os.path.exists(filename):
        os.remove(filename)

In: G = nx.krackhardt_kite_graph()

In:
# GML format write and read
GML_file = dump_file_base + '.gml'
remove_file(GML_file)

nx.write_gml...
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}