检查 Graph 中是否存在边 [英] Checking whether an edge exists in a Graph

查看:12
本文介绍了检查 Graph 中是否存在边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Graphs.jl 包中检查图中是否存在边的首选方法是什么?

What is the preferred method for checking whether an edge exists in a graph in the Graphs.jl package?

假设我们有一个 GenericGraph G,我们想检查一条边 a->b 是否在图中.我想要类似于 has_edge(G, a, b) 的东西,但它似乎不存在.

Say we have a GenericGraph G and we want to check if an edge a->b is in the Graph. I would like to have something similar to has_edge(G, a, b) but that does not appear to exist.

我目前正在使用 in(a, in_neighbors(b, G)) 进行检查,但这可能效率很低.

I am currently using in(a, in_neighbors(b, G)) to check, but that may be quite inefficient.

推荐答案

据我了解,检查图中边的正常方法.这也不是真的低效.

As far as I understand it, that is the normal way to check for an edge in a graph. It's not really inefficient either.

这篇关于检查 Graph 中是否存在边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆