Project Euler Lab - Problem 781

#781 - Feynman Diagrams

● ResearchOfficial difficulty: 94%NetworksTier C - reduced scale in browser; full scale in notebookNot viewed
↖ Euler Lab

Let \(F(n)\) be the number of connected graphs with blue edges (directed) and red edges (undirected) containing:

  • two vertices of degree \(1\), one with a single outgoing blue edge and the other with a single incoming blue edge.
  • \(n\) vertices of degree \(3\), each of which has an incoming blue edge, a different outgoing blue edge and a red edge.

For example, \(F(4)=5\) because there are \(5\) graphs with these properties:

You are also given \(F(8)=319\).

Find \(F(50\,000)\). Give your answer modulo \(1\,000\,000\,007\).

NOTE: Feynman diagrams are a way of visualising the forces between elementary particles. Vertices represent interactions. The blue edges in our diagrams represent matter particles (e.g. electrons or positrons) with the arrow representing the flow of charge. The red edges (normally wavy lines) represent the force particles (e.g. photons). Feynman diagrams are used to predict the strength of particle interactions.

This problem is taken from Project Euler, Problem 781.
Problem text © Project Euler, licensed under CC BY-NC-SA 4.0. Original: projecteuler.net/problem=781. Published Saturday, 15th January 2022, 07:00 pm. Solved by 165 members at time of mirroring.

Why this is useful

Algorithmic Development. Graph/state-space search transfers to routing, dependency resolution, and execution-path optimisation (Phases 16, 17).

We classify relevance honestly - not every Euler problem is a trading application.

Learning mode

Pick how much scaffolding you want. Your choice is remembered per problem.

Scratchpad

Mathematical notes, formulas, pseudocode, hypotheses, complexity notes. Saved automatically with your progress.

Python workbench

Tier C - reduced scale in browser; full scale in notebook
Browser runs a reduced, clearly-labelled educational scale; the original scale is provided in a local notebook.

Real Python (Pyodide) in a sandboxed Web Worker - no network, no filesystem, no DOM access. Ctrl/Cmd+Enter runs. Escape leaves the editor. Stop terminates the worker.

Python runtime not loaded (it boots on first run - a one-time local load).

Check your answer

Answers are checked against a salted hash held in a separate file - not printed in this page. This prevents accidental spoilers; it is not cryptographic protection (see the build notes).

Progressive hints

Confidence

Low confidence schedules this problem for spaced review, even if you solved it.

Reference solution

Spoiler
The complete original explanation (interpretation, naive approach, insight, proof, complexity, Python implementation, tests, common mistakes, alternatives) is hidden and lazy-loaded. Reveal it only after a meaningful attempt - the struggle is where the learning happens.