An undirected graph is given. Find the number of internal stability of the graph. That means finding the power of the largest empty subgraph. (The empty subgraph is one with no vertices directly connected by edges).
I set the edges and vertices. And I'm displaying a list of vertices unconnected by edges.
What should I do next?
reb(a,1,2). % (* 1 ---a--- 2 ---b--- 3 ---d--- 4 ---e--- 6 *)
reb(b,2,3). % (* \_________c_______/ / *)
reb(c,1,3). % (* 7 ---g--- 5 ---f-* *)
reb(d,3,4).
reb(e,4,6).
reb(f,5,6).
reb(g,5,7).
ver(1). % (* empty subgraphs here are *)
ver(2). % (* 145, 146, 147, 245, 246, 247, 35, 36, ... *)
ver(3). % (* the length of the largest of them is 3 *)
ver(4).
ver(5).
ver(6).
ver(7).
edge(A, B) :- reb(_,A,B) ; reb(_,B,A).
nonadjacency(A, B) :-
ver(A), ver(B), \+(edge(A,B)).
do(L) :-
findall( (A,B), nonadjacency (A,B), L), write(L), nl.
dfs(From, To, _, [edge(From, To)]) :-
edge(From, To).
dfs(From, To, VisitedNodes, [(From, X) | TailPath]) :-
edge(From, X),
not(member(X, VisitedNode)),
dfs(X, To, [From | VisitedNodes], TailPath).
reb/3
relation. i.e. 1--2--3--4--6--5--7. or is it not the case? could you just show us the unconnected subgraph in your case please? just the result, not the code. – Will Nessnonadjacency (A,B)
, and a severe singleton variable warning because of theVisitedNode
typo on line 30. Please update the question. – Isabelle Newbie