Graph Editor ! (V0.3.6)

User projects written in or related to FreeBASIC.
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Graph Editor ! (V0.3.6)

Post by Hezad »

A tool to Edit, Analyse, and Render your Weighted/Non Weighted, Oriented/Non oriented graphs.

Latest Graph Editor Version : V0.3.6

Algorithms implemented :
- Kruskal's Minimal spanning tree
- Floyd's PathFinding
- Transitive Closure

DL Here :
--- > Graph Editor.rar < ---

Important Note : IUP lib files are needed to compile the code. (Open GL too)
Last edited by Hezad on Nov 28, 2007 2:34, edited 16 times in total.
Hexadecimal Dude!
Posts: 360
Joined: Jun 07, 2005 20:59
Location: england, somewhere around the middle
Contact:

Post by Hexadecimal Dude! »

This is really great :D

Two things i thought of while using it:

1) I don't have a middle mouse button, so i had to poke some things before using it

2) It would be really nice if you had a button that would beautify the graph, ie try to make it spread out to fill up the whole screen, and try to minimise the number of crossing arcs. I don't know how hard that would be to do.

Anyway, all in all its cool, I really like the look and feel, especially can't wait to see Dijkstra's, Prim's and Floyd's algorithms arrive now there's weights on those edges ;P
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

Thanks for the comment, and thanks for the feedback, I need it :)

1) Yeah I thought of this but totally forget then ! A Cfg file (in which anyone could modify their preferences -> Mouse buttons Handling by example) maybe ?

2) I thought of that to but for now i really don't know how to do this ! Possibilities of graphs are so numerous, I don't know what kind of algorithm I could code (Considering I have the required knowledge to do this oO).

I'll try to code the Dijkstra's, Prim's and Floyd's algorithms too but I have to fix some things before : i'm noticing that my pathfinding algorithm is really buggy yet !
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Re: Graph Editor ! (Made with GraphLib)

Post by AGS »

Hezad wrote:When I started Graphlib some days ago it was just an exercise but in fact, I really liked to code it and to work on graphs. Now, I coded a simple Editor to build, edit, render your graph and make pathfinding on it (Weighted pathfinding not supported yet, but non weighted pathfinding works totally).

You can switch from Oriented to non-oriented and from Weighted to non-Weighted in real time.

The program has two modes for now (Click on the upper buttons to switch from one mode to another) :

- Construction ( Move Vertices / Add Arcs / Add Vertices )
- Pathfinding ( Select path start and path end )



Issues :
- No Save/Load function
- No way to set Weight of arcs
- Some rare bugs
- It needs a better GUI i guess
I use graph - programs to draw simple diagrams. Lately I've been using y - Ed. Nice program but a bit slow (it's a Java - program).

The nice thing about yEd though is that it can read a format called tgf that looks something like this (example made by me):

1 IN-VOICE
2 IN-MEASURE
3 IN-CHORD
4 IN-REST
5 IN-DURATION
6 IN-TUPLE
7 IN-DENOMINATOR
8 IN-NUMERATOR
9 IN-NOTE
10 OUT-VOICE
11 OUT-CHORD
12 OUT-MEASURE
#
1 2
2 6
2 3
2 4
3 5
4 5
9 12
12 10
10 1
6 8
8 7
7 3
5 8

The file starts of with the vertices (numbered 1 to 12). After that (after the #) come the arcs described as pairs of vertices.

You can find a more eleborate description of the tgf - file - format here:
http://www.yworks.com/products/yfiles/d ... ndler.html

I write graphs (tgf - format) with a simple text - editor and use a program (like yEd or maybe someday yours) to display it. The problem with displaying a graph - file lies in the positioning of the vertices and arcs. A program like yEd offers different options for laying out a graph.

But enough about yEd because yEd is part of some commercial package and it is written in Java (not FreeBASIC).

Your program looks nice and...

- I cannot close the program in a 'normal' way.
Pressing ESC does the job but I cannot close the program in the usual way by closing the window the program is executing in (I start the program from Windows 2000 (command - line - shell)).

In your program I can see that you loop until multikey (&h01). Would it be possible to put a message (somewhere on the screen) that states something like 'ESC = exit program'?

- An arc that starts - and ends in the same vertex looks a bit weird
When I click on the right - mouse - button on a vertex an arrowhead gets drawn. A nice arc starting- and ending in the same vertex would be nice(r).

As I was reading your program I couldn't help but wonder what would be faster: drawing lines, circles, handling the mouse etc... the way your program does or using something like GTK to get the job done?
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

Thanks for the comment, it's really appreciated.

1) Y-Ed / TGF format : I didn't know it. I'll search for infos on those. Y-Ed could bring me ideas of course and the TGF looks really interresting to save/load graphs.

2) Closing-App : I forgot that ^^ I'm always using ESC -> easier for testing but using the "Up-right Cross" seems hum.. a bit more logical, that's true :) i'll think about it

3) Arcs From a Vertex to the Same Vertex : I wanted to change that but forgot too, rah I should note those things somewhere. It'll be changed soon.

5) GUI, Mouse/keyboard handling, GFX : Using a library? Yep it's a good idea but I never coded anything with GTK, I should learn to use it but I need to fix all those things before :)

Thanks again !


edit : Concerning the TGF format, can I legally save and load files in this format ?
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

Uploaded a new version.

Fixed :
- Arc-from-a-Vertex-to-itself's GFX
- Window can be closed by the 'X'

Major :
- It can load tgf files ! Create a tgf file called "Graph_Test.tgf" in the same folder of the .bas and .bi files and render :)

That's it for now.
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

Uploaded a New Version.

Graph Editor :
- Added Configuration file : GraphConf.txt (Open it to see how to set your preferences)

GraphLib :
- .TGF Loading Sub ! (Hybrid TGF files : Here, Arcs can't have Text but Weight !)
- .TGF Saving Sub !
- Nice Automatic Rearranging Vertices Corrdinates + Animation
- Vertices can have Text associated


What's Next ?
- A new GUI (IUP? GTK ? Don't know yet.. GTK seems really complicated oO)
- Implementation of Loading/Saving in the Editor
- Implementation of Pathfinding Algorithms (Later..)
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Post by AGS »

Hezad wrote:Uploaded a New Version.

Graph Editor :
- Added Configuration file : GraphConf.txt (Open it to see how to set your preferences)

GraphLib :
- .TGF Loading Sub ! (Hybrid TGF files : Here, Arcs can't have Text but Weight !)
- .TGF Saving Sub !
- Nice Automatic Rearranging Vertices Corrdinates + Animation
- Vertices can have Text associated


What's Next ?
- A new GUI (IUP? GTK ? Don't know yet.. GTK seems really complicated oO)
- Implementation of Loading/Saving in the Editor
- Implementation of Pathfinding Algorithms (Later..)

I've found the 'origing' of the tgf - format and......... the format was thought up by someone working at the university in Bonn (section mathematics). He uses the format for saving/loading graphs. He wrote a program somewhat like you are writing. It is called TreeGraph which is downloadable from here:
http://www.math.uni-bonn.de/people/jmue ... treegraph/

There is no copyright - notice anywhere in sight so I guess you are free to do as you please with the tgf - format. If still in doubt, drop the man that thought up the format an email (he can be reached at the university).

About building a GUI. Using GTK+ is not all that hard. Using glade (Glade - a User Interface Designer for GTK+ and GNOME) makes building a GTK-GUI even simpler. There is an example of using Glade in the example - directory of the FreeBASIC - distribution.

Where to get Glade? http://glade.gnome.org/

Glade/GTK is nice but why not use the dll's that come with windows . Using WIN32 dll's from Microsoft will give you a GUI that looks and feels like.... well, like a Windows GUI I guess :)

And because building a GUI from the ground up is always easier when using a tool you can download a FreeBASIC - editor http://www.radasm.com/fbedit/index.html
that helps you out with building the GUI.
The editor is not flawless but it comes with some examples that can help you get started building a GUI.

GTK or Microsoft dll's? GTK = cross - platform so if that is what you want GTK might be a good choice.
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

AGS >
1 ) Cool, thanks for the info ! This TGF format is really complete oO But a bit too for the "needs" of my program. I just need Vertices / Arcs description and maybe Vertices Coordinates, i don't know yet :)

2 ) Concerning the GUI : I looked over the net for GTK and I doesn't even understood what files I need to compile with GTK ! Still, I found the IUP library - cross-platform too, and relatively easy to implement. And it gave me some ideas. I'm working on it and i'll post the new code when it'll look like something.
I don't want to use win dll's, i'd like to code a totally cross-platform program :)

You talked about IDE's and I thought about using one like Fbedit but in the end I spent the last hours to code using IUP and for now it totally suits my needs.

Anyway, thanks !
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

Hum .. I have a problem building my GUI.

I'm trying to retrieve strings in a file and display them in a MultiLine Object ( IUP library). The point is : when each line has just ONE value, it's OK, but if there are spaces in lines (in the file), The StrVert(i) takes only the last value of the line oO

(here, TextEdit is the multiline Object)

Code: Select all

Line input #Fhandle,StrVert(i)
[...]
IupSetAttributes (TextEdit, "APPEND="+str(StrVert(i)))
I saw on the WIKI that "A line of text does not include the end of line characters. An end of line character may be the LF character (Chr(10)) or the CRLF character pair (Chr(13,10))" and i'm wondering if there are not some confusion in my code between the file's end of line character (LF and CRLF) and the multiline object's end of line character ("/n" in IUP's doc) but I'm working on it since yesterday and I really don't know how I can solve this :\
Lithium
Posts: 298
Joined: Jun 06, 2005 17:53
Location: Nova Scotia, Canada
Contact:

Post by Lithium »

I don't think there's anything wrong with Line Input.. did you try this?..:

Code: Select all

Line Input #Fhandle,StrVert(i)
[...]
IupSetAttributes (TextEdit, "APPEND="+chr$(34)+Str(StrVert(i))+chr$(34))
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

Lithium .. I LOVE YOU

I spent hours to find what were going on.. You resolved my problem with two lines, thanks A LOT ! It totally works now ! I'll post the new code with the GUI in the evening.

edit :

UPDATE :
Graph Editor :
- Implementation of IUP for GUI
- File Access (Open/Save/Save As/New)
- Textbox to edit TGF file
- Any modification in the Main window updates the Textbox (autoUpdate)
- There's a new option in GraphConf.txt which cancels the autoUpdate (Manual Update)

IUP dll's are needed to compile the code so there's the compiled program too. 'don't know if dll's are required or not to execute the exe.
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

Just a note, chr(34) is ugly imo... ;) you can use

"APPEND=""" & StrVert(i) & """"

Code: Select all

print "This is a string ""in quotes"", hehe"
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

Right, code looks nicer :)
Hezad
Posts: 469
Joined: Dec 17, 2006 23:37
Contact:

Post by Hezad »

UPDATE :

Uploaded a new version (V0.1):
- Floyd algorithm is partially implemented (Works only on Non oriented Graph for now. Using it on an oriented Graph can make the program to crash)

What's next ?
- Find a way to make Floyd algorithm to work on oriented Graphs
- Implement Prim's algorithm
- I'm thinking about using a gfx library for visualisation screen like some people advised. Just in brain for now ^^
Post Reply