Ask Your Question

Revision history [back]

This question is similar to https://ask.sagemath.org/question/83230/how-to-find-the-graphs-from-the-following-collection-whose-adjacency-spectral-radius-is-maximum/

# Get list of connected graphs of order 8 and size 9 with a perfect matching
candidates = [g for g in graphs.nauty_geng("8 9:9 -c") if g.has_perfect_matching()]
# Compute the spectral radius
candidates = [(g.spectral_radius(), g) for g in candidates]
# Get the candidate graph with maximum spectral radius
max_radius, best_graph = max(candidates)