Let:
G – the graph
V(G) – the vertices
E(G) – the edges
v,w particular vertices.
the algorithm for building the graph:
//adding v (a new vertex to the graph)
if v has a friend in V (G) then E ← E ∪ {vw|w ∈ V (G)}
G ← (V ∪ v,E)
Can you please give me at least a clue how could I find out if a given graph was built with this algorithm ?
Thank you in advance.
If G has vertices with degree 0, they must have been added after the last “friendly” vertex was added. Remove them. Once we’re finished culling the friendless, there must be a “last friendly vertex added,” identifiable because it’s attached to everything. Find it, remove it, and return to seek-and-destroy-friendless. If the graph is eventually completely destroyed by this process, it can be created by your algorithm.