
Twitter let's you post a 140-character opus out into the ether. Blog entries don't have this 140-character limit -- the end result is that tweets outnumber blogs over the same period of time.
Another key difference is the interconnectedness of twitter users. You follow people and they follow you. This creates an interesting web of users, with messages passed through these connections ("retweets"), and often-rapid conversations taking place.
On top of all this, the Twitter folks provide an extensive API (Application Programming Interface) that lets us write programs to
harvest this vast field of data.
But how do you visualize this ocean of data? A lot of people are developing applications that try to make sense from this seeming chaos. The Twitter API lets you get a list of any user's followers and friends (though the term "friends" has now been replaced with "following").
I decided to see if I could graphically display all my friends and followers.
The Twitter API
This is a RESTful API, so all you need to get the data is a well-formed URL and a tool that can talk HTTP. My scripting language of choice is Perl, so I picked the LWP::Simple Perl module. It comes installed with most recent Linux distributions (Linux is my OS of choice).
First I needed to construct two API URLs: one to get all my friends ("following"), and the other to get my followers. Here's what I used
for me (twitter user @afewwords):
http://twitter.com/friends/ids.xml?screen_name=afewwords
http://twitter.com/followers/ids.xml?screen_name=afewwords
I wrote some Perl code to make these requests. The data I get back is in XML format, so I used the XML::Simple Perl module (available at http://search.cpan.org/ ) to parse the XML and return a list of Twitter IDs. These numeric IDs aren't the twitter user's screen name, you'll have to use yet another API call to get that.
Visualizing Friends and Followers
So now I've got two lists of IDs: friends and followers. Put another way, I have people who I point to (people in my "following" list), and
people who point to me (people in my "followers" list). Graphviz, an open source visualization program ( http://www.graphviz.org/ ) makes it easy to visualize networks (data where nodes connect to each other via arrows).
The Graphviz tools read data in their own programming language, called DOT. Here's a simple DOT program:
digraph HelloWorld {
"me" -> "you";
}
I can use the dot program to convert this program to a graph. Here's the Graphviz command-line to do this:
dot -Tps -o simple.ps simple.dot
This command takes the program, saved in the file simple.dot, and outputs the file simple.ps, a graph image in postscript format. [Graphviz supports many output image formats, including PNG, SVG, and Postscript.] Here's the graph:

I added a Perl subroutine to create a DOT program from my friends and followers lists. The Perl program then feeds the DOT program into a Graphviz program for conversion. Graphviz includes separate command-line programs to render different types of graphs. I experimented with all these programs, but settled on neato. Neato is designed to draw pictures of undirected graphs.
Nodes on the graph, my friends and followers, are represented in different colors. My node, labeled "afewwords", is at the center.
Other twitterers are connected to me by arrows. Arrows move outward from "afewwords" to the people I follower -- these nodes are green. Twitterers who follow me are orange, and these nodes have arrows pointing inward toward "afewwords". Nodes in red are twitterers who are both following and followed by me.
Showing the Twitter IDs isn't as useful as the actual twitter names. To do this, you need to make a Twitter API call for each ID, and you quickly run into the dreaded Twitter API rate limit. An option to return the screen names of friends and followers would be helpful.
Now I'm curious what other information can be gleaned from Twitter. My first attempt only looks at my immediate vicinity -- I could map out another level, showing friends of friends, and so on. Or I might try to weight the graph, attempting to divine the "rank" of each node by how many followers that user has. People are already doing interesting things with the timeline and search
functions in the Twitter API. These are ripe for visualization. I'm open to suggestions.