O'Reilly logo

Graph Analysis and Visualization: Discovering Business Opportunity in Linked Data by David Jonker, Richard Brath

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8 Lightweight Programming

Sometimes you need to go beyond what has been prepackaged even in the most flexible point-and-click software. In graph analysis, programming typically becomes useful in a few areas. This chapter provides some code examples for both Python and JavaScript. Each section starts with a simple introductory example and then builds progressively to more detailed examples.

Often data isn’t quite right and must be cleaned or transformed into a graph. Python is an excellent programming tool for programming novices (and even experts) to quickly create some code to manipulate graph data. Examples in the first part of the chapter include cleaning data—extracting nodes from a data set with only links, and extracting both nodes and links from a data set not organized as a graph (for example, e-mail).

Although Gephi and Cytoscape may seem powerful, sometimes you may want to use other types of visualizations, or perhaps you want to put an interactive graph on a web page. JavaScript is one way to build out lightweight visualizations. The second part of the chapter focuses on JavaScript, the drawing format Scalable Vector Graphics (SVG), and the visualization library D3. The discussion builds incrementally from simple geometry, through simple graphs with rectangular and circular layouts, to interactive force-directed graphs.

Python

If you’ve ever done any programming, Python is quick to learn, has a straightforward syntax, and is fairly forgiving. Python provides ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required