Cycle with Two Leaves
Time limit4sMemory limit1024 MB
Count subgraphs formed by a 4-cycle plus two pendant edges attached to the same cycle vertex, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Graph, Combinatorics, Math
- Solved
- No attempts yet
Problem
You are given an undirected simple graph . Count the number of subgraphs with the following shape.
- Four distinct vertices form one 4-cycle.
- Two other distinct vertices are attached as leaves to the same vertex of that 4-cycle.
Equivalently, the target graph consists of one 4-cycle and two pendant edges incident to the same cycle vertex. Two subgraphs are considered different only when their selected edge sets are different. Extra edges in the original graph that are not selected do not matter. Print the answer modulo .
Input
The first line contains the number of vertices and the number of edges of .
Each of the next lines contains two vertex numbers and joined by an edge.
The graph is simple, and the vertices are numbered from to .
Output
Print the number of subgraphs satisfying the condition, modulo .