algorithm for determining if a given graph matches one of three topologies, based on analysis of adjacency matrix.