Graphics Reference
In-Depth Information
For example, for a distribution list with four items ( Joe , Tim , Ben , Zoe ),
you create six links ( Joe-Tim , Joe-Ben , Joe-Zoe , Tim-Ben , Tim-Zoe ,
and Ben-Zoe ).
Another requirement is that you should create only a single link between a
pairofpeople.Forexample, Ben-Zoe isthesamelinkas Zoe-Ben .Toavoid
duplication of links, always define the links in alphabetical order.
To generate all the unique person-pairs, you use two loops to walk through
all the combinations of people.
# create undirected links:
for i in range(0,len(distlist)):
for j in range (i+1,len(distlist)):
if distlist[i] < distlist[j]:
source = distlist[i]
target = distlist[j]
else:
source = distlist[j]
target = distlist[i]
addLink(source,target,kb)
Writing out the Node and Link Files
The final step is to write out the resulting files. This is similar to the file
written in the previous example. The entire script for creating the e-mail
graph is as follows (using undirected links), with the file write at the end:
import csv
nodemap = {}
linkmap = {}
# define function to find or add node; and add to its
count and size
def addNode(key, kbytes):
if key in nodemap:
node = nodemap[key]
node["count"] += 1
node["size"] += kbytes
else:
Search WWH ::




Custom Search