Quatro cidades A, B, C e D estão ligadas por sSeis...

Creado el: 12 de noviembre de 2025

Respondido usando GPT-5 Thinking por Chat01

Pregunta

Quatro cidades A, B, C e D estão ligadas por sSeis pontes distintas da seguinte maneira:

minus uma ponte liga A e B; minus uma ponte liga B e C; minus uma ponte liga C e D.

minus uma ponte liga A e C; minus duas pontes ligam B e D;

Quantos caminhos são possíveis ligando todas as cidades e passando por todas as pontes uma única vez, sabendo que é permitido passar em uma mesma cidade mais de uma vez?

Python

python
# Let's enumerate Euler trails of the multigraph with vertices A,B,C,D and edges: # AB (1), AC (1), BC (1), CD (1), BD (2) from collections import defaultdict vertices = ['A','B','C','D'] # edges as list of (u,v,label) edges = [ ('A','B','AB'), ('A','C','AC'), ('B','C','BC'), ('C','D','CD'), ('B','D','BD1'), ('B','D','BD2'), ] # adjacency list mapping node to list of edge indices that touch it adj = defaultdict(list) for i,(u,v,lbl) in enumerate(edges): adj[u].append(i) adj[v].append(i) # helper to get the other endpoint def other(i, u): a,b,lbl = edges[i] return b if a==u else a # enumerate Euler trails starting at a given start vertex def euler_trails_from(start): n = len(edges) used = [False]*n res = [] path_vertices = [start] path_edges = [] def dfs(u, used_count): if used_count == n: res.append((path_vertices.copy(), path_edges.copy())) return # explore edges from u not used yet for i in adj[u]: if not used[i]: used[i] = True path_edges.append(i) v = other(i,u) path_vertices.append(v) dfs(v, used_count+1) path_vertices.pop() path_edges.pop() used[i] = False dfs(start, 0) return res trails_C = euler_trails_from('C') trails_D = euler_trails_from('D') len(trails_C), len(trails_D) (16, 16)

Python

python
def trail_endpoints(trails): ends = set() for pv,pe in trails: ends.add(pv[-1]) return ends trail_endpoints(trails_C), trail_endpoints(trails_D) ({'D'}, {'C'})

Pensamiento

Counting Euler trails starting at C

Starting at C gives different paths based on the first edge choice. If I choose AC, the path forces C→A→B, and I continue from B. For the choice BC, I move to B and have a few options — AB, BD1, BD2. Choosing CD leads to D and options BD1 or BD2. Total trail count ends up at 6+6+4.

Counting trails for case CD starting at C

When starting at C with edge CD, I can then move to D choosing between BD1 or BD2. From B, I have three choices: BC, AB followed by AC, or BD. Going to D next seems problematic since it'll leave me stuck. This leads to 4 valid trails in this case, based on previous computations.

Summary of trail counts

Starting with AC, we have 6 trails. Starting with BC or reversing from D both result in 6 trails. By symmetry, we know the start at C→D yields 16 trails. If we count both directions, there are 32 trails. I’ll illustrate this with one example path but will avoid further questions to provide a neat final answer.

Summarizing Euler path reasoning

At vertices A (deg 2), B (deg 4), C (deg 3), D (deg 3), an Euler path exists from C to D. Using a decision tree:

  • CD first: 4 ways
  • Via A first: 6 ways
  • BC first: 6 ways

Total: 16. For both directions, it’s 32. Since BD edges are distinguishable, 32 is the correct answer.

Thought for 2m 1s

Respuesta

Resposta curta:

  • Começando em C e terminando em D existem 16 trilhas eulerianas.
  • No sentido oposto (D → C) há outras 16.
  • Se você contar os dois sentidos como diferentes, dá 32 caminhos; se considerar o caminho e seu reverso como o mesmo, dá 16.

Por quê (bem resumido):

  • Grafo: arestas AB, AC, BC, CD e duas BD (pontes distintas).
  • Graus: d(A)=2d(A)=2, d(B)=4d(B)=4, d(C)=3d(C)=3, d(D)=3d(D)=3. Só C e D são ímpares ⇒ toda trilha euleriana começa em C e termina em D (ou vice-versa).
  • Como d(A)=2d(A)=2, ao passar por A você entra por uma aresta e sai imediatamente pela outra; portanto AB e AC são usadas consecutivamente. Isso equivale a “contrair” A e pensar num grafo com três vértices {B,C,D}\{B,C,D\} e arestas: BCBC (direta), um BCBC via A, CDCD e BDBD em duplicidade.
  • Fazendo a contagem (particionando pelos primeiros passos a partir de C):
    • Usando CDCD primeiro → 4 maneiras;
    • Usando ACAC (i.e., C ⁣ ⁣A ⁣ ⁣BC\!-\!A\!-\!B) primeiro → 6 maneiras;
    • Usando BCBC primeiro → 6 maneiras.
      Soma = 16 no sentido CDC \to D; invertendo o sentido, mais 16.

Portanto, o total é 16 (sem distinguir reversos) ou 32 (distinguindo).

Compartir este Q&A