c0fec0de / anytree

Python tree data library
Apache License 2.0
947 stars 133 forks source link

feat: add support for networkx (optional group/extra) #256

Open dzmitry-lahoda opened 7 months ago

dzmitry-lahoda commented 7 months ago

Add ability to work with anytree as networkx graph.

I am not expert, bad case is to generate networkx graph. May be better to make some adapter?

Networkx can be made optional behind flag (extra/optional group).

I have domain where I work with table data, graph, and tree on basically same data. So need easy move from one representation to other.

Question why anytree to be optionally dependant on networkx but not there way around? Or having 3rd library to make connection? I do not know. So would be have just have such conversion at my hands in anytree or in networkx maintained. Also I questions could be why not deepmind-tree or sqlite or pandas or networkit integration... Answer may be - I do not see anytree claims to be functional generic generalized n-ary tree - it means it may be not ideally composable with others, so some modification will need to be in anytree.

dzmitry-lahoda commented 7 months ago

will donate 30 USD in crypto for this

lverweijen commented 7 months ago

For anytree this might be off-topic but I have recently been thinking about generalizing trees in python (exposing basically the same api as anytree). If you create an issue on https://github.com/lverweijen/AbstractTree/issues, I might be able to help you further.

c0fec0de commented 7 months ago

Will take care next week

Laurent Verweijen @.***> schrieb am Mi., 14. Feb. 2024, 17:34:

For anytree this might be off-topic but I have recently been thinking about generalizing trees in python (exposing basically the same api as anytree). If you create an issue on https://github.com/lverweijen/AbstractTree/issues, I might be able to help you further.

— Reply to this email directly, view it on GitHub https://github.com/c0fec0de/anytree/issues/256#issuecomment-1944190073, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE77IH52NLDWHE7D5CYVZRLYTTRPRAVCNFSM6AAAAABDFF2KMWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBUGE4TAMBXGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dzmitry-lahoda commented 7 months ago

@lverweijen nice graph overview of trees and list of impls. interesting to think of if AbstractTree will work with types well too https://github.com/c0fec0de/anytree/issues/252

Python untyped and likely typed python too are powerful to be unified under some tree abstraction which will allow unified integration with graphs.

@c0fec0de feel free to close issue if it will appear that AbstractTree interface conformance for some future anytree is better than thinking of direct integration with graphs.