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

ForceDirectedの配置不具合 #2

Open
agehama opened this issue May 22, 2022 · 0 comments
Open

ForceDirectedの配置不具合 #2

agehama opened this issue May 22, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@agehama
Copy link
Owner

agehama commented May 22, 2022

以下のコードで0番目と2番目のノードが重なって配置される

#include <Siv3D.hpp> // OpenSiv3D v0.6

#include "GraphDrawing.hpp"

class LabelGraphVisualizer : public BasicGraphVisualizer
{
public:

	explicit LabelGraphVisualizer(const Font& font)
		: BasicGraphVisualizer{}
		, m_labelFont(font)
	{}

	virtual ~LabelGraphVisualizer() = default;

	virtual void drawNode(const Vec2& pos, GraphEdge::IndexType nodeIndex) const override
	{
		m_labelFont(nodeIndex).drawAt(pos);
	}

	Font m_labelFont;
};

void Main()
{
	const ConnectedGraph graph = { {
		{0, 1},
		{1, 2},
		{2, 0},
		{1, 3},
		{3, 4},
	} };

	const LayoutForceDirected layout{ graph, ForceDirectedConfig{.startImmediately = StartImmediately::Yes } };

	LabelGraphVisualizer visualizer{ Font{ 24 } };

	while (System::Update())
	{
		layout.draw(visualizer);
	}
}
@agehama agehama added the bug Something isn't working label May 22, 2022
@agehama agehama self-assigned this May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant