Automorphism group of a graph

8 ビュー (過去 30 日間)
Ben De Schepper
Ben De Schepper 2023 年 7 月 27 日
コメント済み: Zahid 2024 年 3 月 8 日
I'm writing an algorithm to compute the automorphism group of a given graph. I wrote the following code which checks whether any permutation of the nodes yields a graph autmorphism. I have tested this code on small sample graphs (the circle graph with 7 vertices in this code for example), and it works fine. But when I try to test it on a (slightly) bigger graph, say, 50 vertices and 150 edges, it takes very long to compute as the number of permutations of n elements is equal to n!. Does anybody have tips for making this code more efficient to make it useful for graphs with 100 vertices or less?
% Number of vertices
numVertices = 7;
% Create an empty graph
G = graph([], []);
% Add edges to form the circle graph
for i = 1:numVertices
if i == numVertices
G = addedge(G, i, 1);
else
G = addedge(G, i, i+1);
end
end
% Plot the graph
figure;
h = plot(G, 'Layout', 'force');
% Get the adjacency matrix
adjMatrix = adjacency(G);
% Compute the automorphism group using the adjacency matrix
automorphisms = {};
allPermutations = perms(1:numVertices);
for i = 1:size(allPermutations, 1)
permVector = allPermutations(i, :);
permMatrix = zeros(numVertices);
for j = 1:numVertices
permMatrix(j, permVector(j)) = 1;
end
resultMatrix = permMatrix * adjMatrix * permMatrix';
if isequal(resultMatrix, adjMatrix)
automorphisms{end+1} = permMatrix;
end
end
% Convert cell array to matrix format
automorphisms = cat(3, automorphisms{:});
% Display the automorphism group
disp('Automorphism Group Permutations:');
disp(automorphisms);
% Number of automorphisms
numAutomorphisms = size(automorphisms, 3);
disp(['Number of Automorphisms: ', num2str(numAutomorphisms)]);
  1 件のコメント
Zahid
Zahid 2024 年 3 月 8 日
I want to generate regular graph of {8,3} tiling in the form of adjacency matrices for large number of vertices say n=10000. Is that possible to do?

サインインしてコメントする。

採用された回答

Dheeraj
Dheeraj 2023 年 8 月 17 日
Hi,
Your current approach involves trying all permutations of the graph and checking if they preserve the adjacency structure. This approach is inherently expensive, and as you've observed, its runtime grows factorially with the number of vertices.
As computing automorphism group of a given graph is an NP-Complete problem, you could use automorphism libraries like nauty and Traces as they are optimised for graph automorphism problems and are efficient than the brute-force methods.
You could refer to this document on nauty and Traces for better understanding.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by