this week I got this homework to do: count the grade of nodes in a undirected graph and test if there is a euler path in it. the function should work like following:
gradliste([[a,b],[b,c],[b,g],[c,d],[d,e],[e,f],[f,g],[g,h],[c,f]],X).
X = [[a, 1], [b, 3], [c, 3], [g, 3], [d, 2], [e, 2], [f, 3], [h, 1]]
testEulerweg([[a,b],[b,c],[c,d],[d,e],[a,e],[b,d],[b,e],[a,d]]).
true.
my first idea of the functiongradlisteis to 'merge' the graph and generate a list like this:
[a,b,b,c,b,g,c,d,d,e,e,f,f,g,g,h,c,f] then I count numbers of every node. unfortunately I stucked at the merge.
and for the second function testEulerweg I think I should firstly write a function allconnected working like following:
allconnected([[a,b],[b,c],[c,d]]).
true.
allconnected([[a,b],[b,c],[e,f]]).
False.
then I can check if there are none or 2 nodes with odd grade number using the gradliste function.
Can anyone help me on my idea? I'm also open for new ideas:)
thanks in advance
bearzk