Mulai 29 April 2025, model Gemini 1.5 Pro dan Gemini 1.5 Flash tidak tersedia di project yang belum pernah menggunakan model ini, termasuk project baru. Untuk mengetahui detailnya, lihat Versi dan siklus proses model.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Buat docstring dan komentar untuk fungsi Python.
Anda dapat membuat kueri model secara langsung dan menguji hasil yang ditampilkan saat menggunakan
parameter value yang berbeda dengan Konsol Cloud, atau dengan memanggil
Vertex AI API secara langsung.
def dfs(node):
if node in on_stack:
return False # Back-edge found (cycle)
if node in visited:
return True
on_stack.add(node)
visited.add(node)
for neighbor in graph.get(node, []):
if not dfs(neighbor):
return False
on_stack.remove(node)
return True
return all(dfs(node) for node in graph)
Respons
def is_dag_dfs(graph):
"""
Determines if a directed graph is a Directed Acyclic Graph (DAG) using Depth-First Search (DFS).
Args:
graph (dict): A dictionary representing the graph. Keys are nodes, and values are lists of their neighbors.
Returns:
bool: True if the graph is a DAG, False otherwise.
"""
visited = set()
on_stack = set() # Track nodes on recursion stack
def dfs(node):
"""
Performs Depth-First Search starting from a given node.
Args:
node (object): The node to start the DFS from.
Returns:
bool: True if no cycle is detected, False otherwise.
"""
if node in on_stack:
return False # Back-edge found (cycle)
if node in visited:
return True
on_stack.add(node)
visited.add(node)
for neighbor in graph.get(node, []):
if not dfs(neighbor):
return False
on_stack.remove(node)
return True
return all(dfs(node) for node in graph)
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-02 UTC."],[],[]]