Transforming undirected trees into rooted directed trees

7 views
Skip to first unread message

Hola

unread,
May 23, 2025, 1:12:26 PMMay 23
to Macaulay2

I'm working with the NautyGraphs package in Macaulay2, and I use it to generate all triangle-free connected graphs with a fixed number of vertices, which gives me all undirected trees.

-- For example:

g = generateGraphs(10, OnlyTriangleFree => true, OnlyConnected => true);  

stringToGraph g_5

gives me something like:

Graph{ 0 => {8, 9}, 
1 => {8}, 
2 => {8}, 
3 => {9}, 
 4=> {9}, 
5 => {9}, 
6 => {9}, 
7 => {9}, 
8 => {0, 1, 2}, 
9 => {0, 3, 4, 5, 6, 7}
}

What I'd like to do is:

  1. Transform each undirected tree in the list g into a directed rooted tree, where I choose vertex 0 as the root.

  2. Remove rooted trees that are isomorphic as directed trees (i.e., same structure up to relabeling).

For example, I want to treat these two as equivalent and keep only one:

  • 0 => {1,2}, 1 => {3}, 2 => {}, 3 => {}

  • 0 => {1,2}, 1 => {}, 2 => {3}, 3 => {}

So my questions are:

  • Is there a recommended way in Macaulay2 (or external tools) to convert these undirected trees to rooted directed trees, choosing a fixed root like 0?

  • Is there a known method (in Macaulay2 or externally) to test isomorphism of rooted directed trees so that I can remove duplicates? Nauty allows to use "removeIsomorphs", so I could use it before trasforming in directed rooted trees, or it has a kind of controindication?

Any suggestions or references would be appreciated!

Reply all
Reply to author
Forward
0 new messages