Implement a function count_connected_segments(n, edges) that counts the number of connected segments in an undirected graph represented by nodes and edges. A connected segment is defined by nodes that are consecutively numbered without any gaps.
Input Requirements
The function should accept two parameters:
n (int): The number of nodes in the graph, where nodes are indexed from 1 to n.
edges (list of tuples): A list of tuples representing edges in the graph. Each tuple (a, b) indicates an edge connecting node a to node b.
Output Requirements
The function should return an integer representing the total count of connected segments in the graph.
Constraints
1 <= n <= 1000
Each edge a and b must satisfy 1 <= a, b <= n.
There may be multiple edges between the same pair of nodes but no self-loops.
Implementation
Your solution must be implemented in a file called /app/solution.py. The file should contain the complete implementation of the count_connected_segments function as per the description above.