We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
build a graph (Read 1834 times)
build a graph
Dec 20th, 2007, 6:45pm
 
hello,
I posted some questions here: http://processing.org/discourse/yabb_beta/YaBB.cgi?board=LibraryProblems;action=display;num=1198009655

Probably, my mind wasn't advanced/experienced enough in this little work.

I went further.

But I need some ideas again.

I need to build a network/graph.
I could divide the job in 2 steps or not
2 steps= collect data (I mean, collect XML file and build a structure, a kind of array of arrays etc) + explore the structure previously built and progressively build the graph/network.

How could I do that with processing ? I mean, how could i do that real-time?


I can summarize:
I have a seed (=a name of user)
I can have this user xml file in which all his friends are stored.
I begin to build the structure:
first element = [ (username1) - [ (friend1 - strongnessOfFriendship) - (friend2 - strongnessOfFriendship)] - etc etc etc  ]
I'd like to do the same for all friends of the first element

and keep going on etc etc

each process generates a new generation i.e a new depth in the graph.

I need to build link too but it could be done while exploring for drawing nodes, I guess.

any ideas, experiencies ?

I may have big lack of experiencies in coding,hashing etc Wink
Re: build a graph
Reply #1 - Dec 20th, 2007, 7:59pm
 
1) Why don't you use the core xml library? Doesn't it fit your needs? You can easily open an XML file :

Code:
XMLElement xml = new XMLElement(this, "sites.xml"); 


Then, you can parse it, find the reference to other XML files, and so on.

2) To store the data, you can use a custom User class containing an ArrayList (java.util.ArrayList) which collects the references to the user's friends.

Then, you put the first user on the graph, iterate through it's friends list, put his friends on the graph, etc. You'll have to proceed nested iterations.
Re: build a graph
Reply #2 - Dec 20th, 2007, 10:25pm
 
hi antiplastik,

*XMl
I'm using proXML lib.
it works fine, no problem.

I just have a little problem.
the call of  xmlIO.loadElement() (after definition XMLInOut xmlIO;) create a call to xmlEvent()
ok, but when I make a for loop to:
1) begin with the seed, read the first user xml file => create the first line of my global table
2) for each friends of the first user, search for the correct xml file & create all the lines in the global table
3) etc etc til a variable (depth, for instance) reach 3 or 4 or ..

... I have a prob because the inclusion is slower than the loading of XML file ... it causes exceptions etc...

you mean I should use core XML instead of proXML lib??



*Storing
I created a 2 structures :
__________________________________________
class user_friendshipness {
String name;
float simil;
 user_frienshipness(String namei,float friendshipness)
 {
 this.name = namei;
 this.friendshipness = simili;
 }
}

class global_table{
String name;
global_table[] simil_table;

 global_table(String namei, user_friendshipness[] simil_tablei)
 {
 this.name = namei;
 this.friendshipness_table = friendshipness_tablei;
 }
}
__________________________________________

they work fine too, but...

my main problem is about the conception of the code.
I don't want to go further without several thoughts about that

should I build my global table with all user, friendshipness informations AND after that draw the network by exploring the global table ??
is it cleverer to draw the network while storing information (time won't be wasted...) ??

I'm using traer physics & animations too. it works fine.
but I need to have an index for each particle...
I'll explore it later, when I'll find my code concept for this project..

Page Index Toggle Pages: 1