← 返回 akunacapital 的题目列表Counting K-Star Graphs
类型:online_judge
Given an integer k and an undirected simple graph, count and return the number of k-star graphs present in the graph. A k-star graph is defined as a simple path from a central node to k distinct nodes.
Input:
edges: A set of graph edges consisting of tuples (u, v).
k: An integer less than or equal to the number of nodes in the graph.
Output:
An integer representing the number of k-star graphs.
Example: Input: edges = [(1, 2), (1, 3), (1, 4), (2, 3), (3, 4)], k = 2 Output: 2
Constraints:
Number of nodes in the graph does not exceed 1000, and number of edges does not exceed 2000.
Example
Input
[(1, 2), (1, 3), (1, 4), (2, 3), (3, 4)] 2