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

Find cycles result is wrong! #323

Open
sonygod opened this issue Mar 13, 2019 · 2 comments
Open

Find cycles result is wrong! #323

sonygod opened this issue Mar 13, 2019 · 2 comments

Comments

@sonygod
Copy link

sonygod commented Mar 13, 2019

image

//the result only get 3 circles?

	const vertexA = new GraphVertex('A');
	const vertexB = new GraphVertex('B');
	const vertexC = new GraphVertex('C');
	const vertexD = new GraphVertex('D');
	const vertexE = new GraphVertex('E');
	const vertexF = new GraphVertex('F');
	const vertexM = new GraphVertex('M');
	const vertexN = new GraphVertex('N');

	const edgeAM = new GraphEdge(vertexA, vertexM);
	const edgeAD = new GraphEdge(vertexA, vertexD);
	const edgeAE = new GraphEdge(vertexA, vertexE);

	const edgeDE = new GraphEdge(vertexD, vertexE);
	const edgeDN = new GraphEdge(vertexD, vertexN);


	const edgeEM = new GraphEdge(vertexE, vertexM);
	const edgeEF = new GraphEdge(vertexE, vertexF);
	const edgeEN = new GraphEdge(vertexE, vertexN);




	const edgeFM = new GraphEdge(vertexF, vertexM);
	const edgeFB = new GraphEdge(vertexF, vertexB);
	const edgeFC = new GraphEdge(vertexF, vertexC);
	const edgeFN = new GraphEdge(vertexF, vertexN);


	const edgeBM = new GraphEdge(vertexB, vertexM);
	const edgeBC = new GraphEdge(vertexB, vertexC);

	const edgeCN = new GraphEdge(vertexC, vertexN);

	const graph2 = new Graph();


	graph2
	  .addEdge(edgeAM)
	  .addEdge(edgeAE)
	  .addEdge(edgeAD)
	  .addEdge(edgeDN)
	  .addEdge(edgeDE)
	  .addEdge(edgeEF)
	  .addEdge(edgeEM)
	  .addEdge(edgeEN)
	  .addEdge(edgeFM)
	  .addEdge(edgeFN)
	  .addEdge(edgeFB)
	  .addEdge(edgeFC)
	  .addEdge(edgeBM)
	  .addEdge(edgeBC)
	  .addEdge(edgeCN);

	var resultC=detectUndirectedCycle(graph2);  

	console.log(resultC);
@ktrongnhan
Copy link

Hi @sonygod,
Can you show me the 3 cycles you got ?
For my own try, I only get one : A - E - M - A which does seem to be correct as detectUndirectedCycle() is merely supposed to find out whether or not there is a cycle in a given graph

Hi @trekhleb,
Does it sound reasonable to you ?

@ktrongnhan
Copy link

Duplicate of #252

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

No branches or pull requests

2 participants