Bird
0
0

Given the following code snippet, what will be the output of printing the graph's nodes?

medium📝 state output Q4 of 15
LangChain - LangGraph for Stateful Agents
Given the following code snippet, what will be the output of printing the graph's nodes?
graph = MultiAgentGraph()
agent_a = Agent('A')
agent_b = Agent('B')
graph.add_node(agent_a)
graph.add_node(agent_b)
print(graph.nodes())
AError: nodes() method not found
B['A', 'B']
C[agent_a, agent_b]
D[Agent('A'), Agent('B')]
Step-by-Step Solution
Solution:
  1. Step 1: Understand add_node behavior

    Adding agent objects stores them as nodes in the graph.
  2. Step 2: Printing nodes() returns list of agent objects

    So output shows list with Agent('A') and Agent('B') objects.
  3. Final Answer:

    [Agent('A'), Agent('B')] -> Option D
  4. Quick Check:

    Graph nodes output = Agent objects list [OK]
Quick Trick: Nodes() returns agent objects, not just names [OK]
Common Mistakes:
MISTAKES
  • Expecting string names instead of objects
  • Assuming nodes() method does not exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes