Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: In search of an algorithm for loading cyclic graphs

by samtregar (Abbot)
on May 17, 2005 at 18:43 UTC ( #457940=note: print w/replies, xml ) Need Help??


in reply to Re^3: In search of an algorithm for loading cyclic graphs
in thread In search of an algorithm for loading cyclic graphs

I'm not understanding something because that looks like you're creating a table for each node type and the rows of said tables are the edges.

You've got it. The only part you're missing is that isn't "just" a graph system. It's Krang, the purpose of which is not to be a general graph implementation but rather to publish webpages. The fact that dumping and loading data is essentially a cyclic-graph-loading problem is more a side-effect than a design goal.

In this case each node type is a completely different kind of data - stories, templates, media, categories, users, etc. The links are forgeign keys in the tables, category_id in the media table for example.

Does that make sense?

-sam

  • Comment on Re^4: In search of an algorithm for loading cyclic graphs

Replies are listed 'Best First'.
Re^5: In search of an algorithm for loading cyclic graphs
by dragonchild (Archbishop) on May 17, 2005 at 18:52 UTC
    So, the links are literally that - actual weblinks. *ponders*

    Either way, it doesn't matter. Create a links table and load that after loading all the nodes in their various types. That's the cleanest solution. Loading the links at the same time as the nodes is going to run into problems with cycles. But, you already knew that.

    An alternate solution is what Data::Dumper does and that's to keep track of what nodes have been seen before and stop following the tree when you find somewhere you've been. I don't know if that will work, given the code you've already written.


    • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
    • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
      So, the links are literally that - actual weblinks.

      Sometimes. Story to story links are usually real links. Story to user links, for example, aren't. They link a story to the user that created the story. There are more non-weblinks in the system than weblinks.

      Both your solutions are reasonable. In fact, what I'm doing now is sort of like both. Neither is what I'm after here, but maybe what I'm after doesn't exist.

      -sam

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://457940]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2023-02-08 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?