Question about drawing simple graph in Python?

Anton Vredegoor anton at vredegoor.doge.nl
Tue Nov 12 08:17:50 EST 2002


On Mon, 11 Nov 2002 13:58:32 -0800 (PST), Mindy <csshi99 at yahoo.com>
wrote:

>Thanks so much. This really produces the graph with
>edges and nodes. But I have two more questions.
>
>1) How to stick a name to the node? For example, the
>current edge is just a line like:
>  ------------>
>But I want there're nodes' names attached to each
>node, such like:
>
>  pt1--------->pt2
>
>How to draw the above edge?

At the moment I am reading messages about how to handle questions from
new users, so I'll try to do my best to find a friendly way to escape
this question without giving you the feeling of being brushed off :-)

What is necessary to "stick a name to the node" is to use text labels,
and once one is familiar with tkinter it's not a hard thing to do at
all. Explaining how to use text labels in tkinter to someone not
knowing the basics of tkinter however is only possible with sky hooks
which I don't have available at the moment.

So the limits of my example script seem to have been reached, unless
of course you are willing to learn tkinter programming, which will
take about a week I guess. If you can spare the time it's highly
advisable to do so, because - provided you stay with Python - sooner
or later you will have to do it anyway - it's Python's standard GUI -,
and why not have this basic knowledge available right at the
beginning?

So find a tkinter tutor (http://www.pythonware.com) or something like
that and come back in a week or so with some code to this list and I
am sure some people will help you fix it.

On the other hand now that you've got an example of tkinter
programming it's also a good option to stop now for the time being and
start comparing it with other GUI's. Yet another option is to use one
of the ready to go visualization tools that others have suggested.

>2) I met such situation:
>I have edges (pt1,pt2) (pt2,pt3) (pt1,pt3)
>But when I draw, I only get:
>  pt1----->pt2------>pt3
>which doesn't show there's an edge between (pt1,pt3).
>Because the line between pt1 and pt2 overlaps with the
>lines between pt1,pt2 and pt2,pt3. How to fix this?

This seems to be a rather basic problem which probably needs adding
another dimension to the visualization. There is a tool to visualize
3D objects, its called Visual Python and it's surprisingly easy (for a
3D visualization tool) to learn, and it has labels and arrows. Its at:

http://cil.andrew.cmu.edu/projects/visual

I am glad you like my script and please let the fact that I can't help
you much with it now not give you the idea that your feedback is not
valuable. Hmmm, now I have trouble myself to count the double
negations, so let's just say this: It is very valuable for me to know
how my script is used and where it's limits are.

Regards,
		Anton.





More information about the Python-list mailing list