Python – What format is used to store graphics

What format is used to store graphics… here is a solution to the problem.

What format is used to store graphics

I’m working on a project that involves working on charts extracted from other sources. Currently we are using Python’s networkx module for analyzing graphs.

I am now faced with the task of choosing a graphics storage format. Pickle seems to be a good choice for a purely python-based solution. However, we are now in the prototype design phase, and it is very likely that we will have to switch to C++ to solve the performance and scalability problems.

Therefore, I want to store my drawings in a format that is widely supported by most graphics libraries to minimize the headaches faced by future contributors in the project.

Can you give me some advice on which format I should use?

Solution

TGF is your solution.

Python example:

 #!/usr/bin/python

import fileinput, re

depends = {}
for line in fileinput.input():
    m = re.match('(.+):\s*(.*)',line) # find every depenency line of the form "<item>: <dependencies>"
    if m:
        item = m.group(1)
        dependency_list = m.group(2)
        print item,item # node definition

if dependency_list: # there are dependencies
            depends[item] = dependency_list.split() # store the list into a dictionary for later

print "#" # end of node list, start of edge list

for item in depends:
    for dependency in depends[item]:
        print item,dependency # edge definition

Related Problems and Solutions