Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Hierarchy from arbitrary ordering. #218

Closed
JoOkuma opened this issue Nov 17, 2020 · 4 comments
Closed

[FEATURE] Hierarchy from arbitrary ordering. #218

JoOkuma opened this issue Nov 17, 2020 · 4 comments
Labels
feature request Feature request

Comments

@JoOkuma
Copy link
Contributor

JoOkuma commented Nov 17, 2020

Hello, Benjamin

I need to build a hierarchy from an arbitrary ordering of the graph edges.

Do you think this is relevant and could be merged into the main branch?

I will probably just make a function similar to the c++ bpt_canonical but without the edge_weights parameter and the stable_sort call.

Best,

@PerretB
Copy link
Member

PerretB commented Nov 17, 2020

Hi Jordão,

just to be sure to understand:

  • do you have already sorted edge-weights ? or
  • do you want edges to be taken in an arbitrary (random) order ?

FYI: I'm planning to do a refactoring of this part of the library in near future

@JoOkuma
Copy link
Contributor Author

JoOkuma commented Nov 17, 2020

It is closely related to the second item. I don't want to use the edge-weight for ordering. I want to give the ordering my self as an argument to build the tree.

@PerretB
Copy link
Member

PerretB commented Nov 17, 2020

OK I see, I plan to add this feature in the future interface. For the moment an easy way to do it is to use the ranks in your ordering as edge weights. E.g.

# complete graph with 3 vertices
g = UndirectedGraph(3)
# the edges are (in order) {0,1}, {0, 2}, and {1,2}
g.add_edges([0, 0, 1], [1, 2, 2])

# assume that we want to take edges in the following order {0,2} (rank 0), {1, 2} (rank 1) and {0,1} (rank 2)
rank_weights = [2, 0, 1]

tree, altitudes = bpt_canonical(g, rank_weights)

@PerretB PerretB added the feature request Feature request label Nov 17, 2020
@JoOkuma
Copy link
Contributor Author

JoOkuma commented Nov 17, 2020

ok, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request
Projects
None yet
Development

No branches or pull requests

2 participants