小编fun*_*all的帖子

如何在广度优先搜索中跟踪深度?

我有一棵树作为广度优先搜索的输入,我想知道算法在哪个级别进展?

# Breadth First Search Implementation
graph = { 
    'A':['B','C','D'],
    'B':['A'],
    'C':['A','E','F'],
    'D':['A','G','H'],
    'E':['C'],
    'F':['C'],
    'G':['D'],
    'H':['D']
    }


def breadth_first_search(graph,source):
    """
    This function is the Implementation of the breadth_first_search program
    """
    # Mark each node as not visited
    mark = {}
    for item in graph.keys():
        mark[item] = 0

    queue, output = [],[]

    # Initialize an empty queue with the source node and mark it as explored
    queue.append(source)
    mark[source] = 1
    output.append(source)

    # while queue is not empty
    while queue:
        # …
Run Code Online (Sandbox Code Playgroud)

algorithm graph graph-algorithm data-structures

16
推荐指数
4
解决办法
2万
查看次数

如何在 Python Dash 中的两个 dcc 组件之间留出空间?

Dash 中  (空格)的 HTML 等价物是什么?

html.Div(
    [
      dcc.Input(),
      <add horizontal space here> 
      dcc.Input()
    ]
)
Run Code Online (Sandbox Code Playgroud)

python plotly plotly-dash plotly-python

9
推荐指数
1
解决办法
1万
查看次数