0

Here is an image of the Roslyn Syntax Visualizer tool (part of Visual Studio):

Roslyn Syntax Visualizer Graph

As I can see we can use the View Directed Syntax Graph command to display this syntax tree window:

Roslyn Syntax Graph

My question is: Why this window is called Syntax Graph but not Syntax Tree?

Is it because every tree is a graph, but then why didn't they choose the name Syntax Tree as more convenient? Why generalize with the Graph term?

If the syntax tree can be cyclic then can you provide me with an example of C# syntax being a Syntax Graph?

Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123
  • 3
    This sounds like a great question for the IDE team, but... as a coding question here - I'm unclear what you want us to do expect speculate. – Marc Gravell Nov 13 '18 at 09:18
  • 1
    Can also downvoters explain their votes :) If you can't provide an example of C# syntax tree having cycles therefor being a graph, please do not downvote so others can answer this :) – Nikolay Kostov Nov 13 '18 at 09:29
  • I'm wondering whether it would be possible to construct a graph with a node having multiple parents. This wouldn't be a cycle (per se) unless we ignore the directedness. And I doubt any normal C# code represented as source files could produce such a graph either. – Damien_The_Unbeliever Nov 13 '18 at 09:32
  • 1
    I think it's a matter of picking your battles/consistency. When you select that menu option, it spits out a `.dgml` file and opens them in the "Graph Document Editor" (Or, presumably, the "Graph Document Viewer". Which one you have depends on VS edition, I can only see the editor, your screenshot is showing the viewer). DGML files are generic and can contain any type of graph, not just trees. If it's open in the editor, you can add and remove nodes and links, so can easily end up with something that isn't a tree. – Damien_The_Unbeliever Nov 13 '18 at 10:14
  • Thank you, @Damien_The_Unbeliever it does make sense. – Nikolay Kostov Nov 14 '18 at 08:48

1 Answers1

1

That's mostly cause Tree is a Graph ... that is A tree is a graph that has no cycles

Rahul
  • 76,197
  • 13
  • 71
  • 125