views:

85

answers:

4

First of all, sorry for the title. Someone please propose a better one, I really didn't know how to express my question properly.

Basically, I'm just looking for the name of a data structure where the elements look like this (ignore the dots):

......5

....3...2

..4...1...6

9...2...3...1

I first thought it could be a certain kind of "tree", but, as wikipedia says:

A tree is [...] an acyclic connected graph where each node has zero or more children nodes and at most one parent node

Since there can be more than one parent by node in the data structure I'm looking for, it's probably not a tree.

So, here's my question:

What is the name of a data structure that can represent data with the following links between the elements? (/ and \ being the links, again, ignore the dots):

......5

...../..\

....3...2

.../..\./..\

..4...1...6

../.\./..\./..\

9...2...3...1

+4  A: 

I think it isn't totally wrong to call it a Tree, although "Digraph" (directed graph) would be a more proper term.

First of all, sorry for the title. Someone please propose a better one, I really didn't know how to express my question properly.

The title is fine, I LOL'd hard when I opened the question. I am going to start calling them "Bowling Pins" now :)

alt text

      5

    3   2

  4   1   6

9   2   3   1
NullUserException
Thank you, but do you know what type of tree would represent it?
Jesse Emond
@Jesse answer updated
NullUserException
+1 Was there any need for including the pins pic ?Surely no. Got a smile from me? Definetly yes.
Tom
+2  A: 

Since there can be more than one parent by node in the data structure I'm looking for, it's probably not a tree.

What you're looking for is probably a graph. A tree is a special case of a graph where each node has exactly one parent. (except the root which has none)

casablanca
1 (mid-level), 2, and 3 have two parents in the OP's example
Mr Fooz
Oops, didn't notice that.
casablanca
+2  A: 

A "dag", or directed acyclic graph, is a graph with directed edge in which there may be multiple paths to a node, and some nodes may have both incoming and outgoing edges, but there is no way to leave any node and return to it (there are no cycles). Note that in a finite DAG at least one node must have nothing but outgoing edges and at least one must have nothing but incoming edges. Were that not the case, it would be possible to move continuously through the graph without ever reaching a dead end (since every node would have an exit), and without visiting any node twice (since the graph is acyclic). If there are only a finite number of nodes, that's obviously impossible.

supercat
+3  A: 
Pavel Shved