<p>Yes, scene graphs can be non-tree graphs. Your question is a little vague, but assuming you're talking about something like the scene graph in rendering a frame of video, for say a feature film, then yes, there are often references between objects. For example, in a compositing application, you might have a piece of footage with an effect applied. The effect may have as one of its inputs another piece of footage which is also in the scene. (It might use the other image for blending, as a reflection map, as a diffuse or specular lighting map, a bump map etc.) So you could have a scene that looks like this:</p>

<pre><code>scene contains:
    footage A contains:
        filter "Multiply Blend" which takes input:
            footage B
    footage B
    footage C
</code></pre>

<p>In something like a game, you might objects that refer to other objects that they can collide with:</p>

<pre><code>scene contains:
    ground which can collide with:
        player
        ball
        goal
    player which can collide with:
        ground
        ball
        goal
    ball which can collide with:
        player
        ground
        goal
</code></pre>

<p>etc.</p>

CC BY-SA 3.0
2018-01-27T09:30:57.180Z
Sorry, my question was indeed a little vague. I had in mind scene graphs for 3D rendering. The collision examples are a bit too much into the app-specific side of things from my point view. At the app level, it's easy to imagine almost anything as a graph of relationships between different objects. However, as pointed out by @Rahul, one example is when multiple nodes with different transformations share the same geometry, in that case it's a non-tree graph.
Mei Zhang
CC BY-SA 3.0
2018-01-27T06:50:30.843Z
2018-01-27T06:50:30.843Z
user1118321
<p>All "scene graphs" I've seen in practice are actually trees, but I have some vague memories about somebody saying a while ago that sometimes they can actually be graphs (technically, trees are already graphs, but you get the point).</p>

<p>If they can actually be graphs, what are some practical examples?</p>

<p>If they're always just trees, is there some history behind why it was originally called "scene graph"?</p>

CC BY-SA 3.0
2018-01-27T09:24:26.123Z
I completely missed that common use case, that's a very practical and clear example. Thanks.
Mei Zhang
CC BY-SA 3.0
2018-01-27T13:50:07.987Z
@Rahul You should post that as an answer, even though it's short. It's exactly the example the questioner was looking for.
Dan Hulme
<data-structure><scene-graph>
is a scene graph actually a tree?
Mei Zhang
# is a scene graph actually a tree?

(Asked by: username_0 on 2018-01-27)

All "scene graphs" I've seen in practice are actually trees, but I have some vague memories about somebody saying a while ago that sometimes they can actually be graphs (technically, trees are already graphs, but you get the point).

If they can actually be graphs, what are some practical examples?

If they're always just trees, is there some history behind why it was originally called "scene graph"?

**Tags:** data-structure, scene-graph

> **Comments:**
> **username_0**: I completely missed that common use case, that's a very practical and clear example. Thanks.  
> **username_1**: @Rahul You should post that as an answer, even though it's short. It's exactly the example the questioner was looking for.  

---

## 1 answers

### Answer by username_2 on 2018-01-27. Score: 2

Yes, scene graphs can be non-tree graphs. Your question is a little vague, but assuming you're talking about something like the scene graph in rendering a frame of video, for say a feature film, then yes, there are often references between objects. For example, in a compositing application, you might have a piece of footage with an effect applied. The effect may have as one of its inputs another piece of footage which is also in the scene. (It might use the other image for blending, as a reflection map, as a diffuse or specular lighting map, a bump map etc.) So you could have a scene that looks like this:

```
scene contains:
    footage A contains:
        filter "Multiply Blend" which takes input:
            footage B
    footage B
    footage C

```

In something like a game, you might objects that refer to other objects that they can collide with:

```
scene contains:
    ground which can collide with:
        player
        ball
        goal
    player which can collide with:
        ground
        ball
        goal
    ball which can collide with:
        player
        ground
        goal

```

etc.

> **Comments:**
> **username_0**: Sorry, my question was indeed a little vague. I had in mind scene graphs for 3D rendering. The collision examples are a bit too much into the app-specific side of things from my point view. At the app level, it's easy to imagine almost anything as a graph of relationships between different objects. However, as pointed out by @Rahul, one example is when multiple nodes with different transformations share the same geometry, in that case it's a non-tree graph.  

---

