组织树绘制算法

发布于 2024-10-19 05:36:08 字数 271 浏览 2 评论 0原文

我正在 C# 中实现一个组织树图 - 从上到下或从左到右 - 并寻找一个好的算法来绘制树。有什么建议吗?

谢谢

更新

我终于有一些时间来研究它,所以最终编写了自己的库来通过创建自定义面板来存储和绘制树,不确定我是否遵循特定的算法,我只是编写了我的库自己 - 回到笔和纸 + 时间:)

一旦我添加完我想要的所有功能,我打算将其在 Codeplex 上开源。一旦在 Codeplex 上发布,将发布另一个更新。

谢谢

I'm implementing an organizational tree graph - top to bottom or left to right - in C# and looking for a good algorithm to draw the tree. Any recommendations?

Thanks

Update

I finally had some time to work on it so ended up writing my own library to store and draw the tree by creating a custom panel, not sure if I followed a particular algorithm, I just wrote my own - back to pen and paper + time :)

I intend to make it open source on codeplex once I'm done adding all the features I wanted. Will post another update once it's up on codeplex.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

海风掠过北极光 2024-10-26 05:36:08

我认为您正在寻找的关键字是基于力的算法

I think the keyword you're looking for is Force-based algorithms.

却一份温柔 2024-10-26 05:36:08

如果您只使用标准 Silverlight,也是可以的。
将 ItemsControl(它具有 StackPanel 作为 ContainerTemplate,因此您可以垂直或水平显示项目)与 HierarchicalDataTemplate 结合使用。
显示您使用 ItemTemplate 设置的项目的方式,它应该可以直接工作

Also possible if you use just standart Silverlight.
Use an ItemsControl (which has as ContainerTemplate a StackPanel, so you can display the items the vertically or horizontally) in combination with HierarchicalDataTemplate.
The way to display the items you set with ItemTemplate and it should work directly

你在看孤独的风景 2024-10-26 05:36:08

您可以使用一个很酷的可视化来代替绘制树,那就是方形树图。它是分层数据结构的视图,显示了打包到矩形中时叶节点的相对大小。因为它是递归绘制的,所以如果两个叶节点位于层次结构的不同大小的子树中,它们将被绘制为不同的大小。

http://en.wikipedia.org/wiki/Treemapping

A cool visualization you can use instead of drawing the tree is a Squarified Treemap. It's a view of a hierarchical data structure that shows the leaf nodes' relative sizes when packed into a rectangle. Because it is drawn recursively, two leaf nodes will be drawn different sizes if they are in different size subtrees of the hierarchy.

http://en.wikipedia.org/wiki/Treemapping

残花月 2024-10-26 05:36:08

您可能考虑的一种选择是简单地使用 TreeView 控件并进行转换以使其按您希望的方式显示。

http://forums.silverlight.net/forums/p/149065/334501.aspx老实说

,我认为使用第三方组件将是一个更好的“算法”,而不是重新发明。如果您应该考虑一下,有几种产品可以为 SL 提供此功能:

http ://www.nwoods.com/components/silverlight-wpf/goxam-overview.htm
http://www.mindfusion.eu/diagramlite.html
http://www.syncfusion.com/products/user-interface-edition /silverlight/图表
http://www.yworks.com/en/products_yfilessilverlight_about.html

One option you might consider is to simply use the TreeView control and transforms to make it appear the way you want it to.

http://forums.silverlight.net/forums/p/149065/334501.aspx

Honestly, I think using a third-party component would be a much better "algorithm" rather than re-inventing. If you should consider, there are several products that offer this capability for SL:

http://www.nwoods.com/components/silverlight-wpf/goxam-overview.htm
http://www.mindfusion.eu/diagramlite.html
http://www.syncfusion.com/products/user-interface-edition/silverlight/diagram
http://www.yworks.com/en/products_yfilessilverlight_about.html

南冥有猫 2024-10-26 05:36:08

这是我在这个主题上找到的最好的文章: WPF 的图形树绘图控件

它有 WPF 和 Silverlight 版本。它实现了 John Q. Walker II 算法来定位节点并且工作完美。我仍然需要进行旋转,以便它可以从左到右显示。目前只是从上到下。

您可以在此处找到有关该算法的更多信息:http://www.cs.unc .edu/techreports/89-034.pdf

This is the best article I have found on this subject : A Graph Tree Drawing Control For wpf

It has a WPF and Silverlight version. It implements John Q. Walker II algorithm for positioning nodes and works perfectly. I still have to work on the rotation so it can be displayed left to right. Currently is only top to bottom.

You can find more info on the algorithm here: http://www.cs.unc.edu/techreports/89-034.pdf

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文