You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取DiMultigraph中按添加顺序排列的非排序边列表?

获取有向多重图按添加顺序排列的边列表

问题描述

我定义了如下有向多重图:

G=DiMultigraph(4)
add_edge!(G,2,4)
add_edge!(G,4,1)
add_edge!(G,4,1)
add_edge!(G,1,3)
add_edge!(G,1,3)
add_edge!(G,2,3)

运行以下代码后:

e=edges(G)
e1=collect(e)

得到的是排序后的边列表:

Multiple edge 1 => 3 with multiplicity 2
Multiple edge 2 => 3 with multiplicity 1
Multiple edge 2 => 4 with multiplicity 1
Multiple edge 4 => 1 with multiplicity 2

但我需要的是按添加顺序排列的非排序边列表:

Multiple edge 2 => 4 with multiplicity 1
Multiple edge 4 => 1 with multiplicity 2
Multiple edge 1 => 3 with multiplicity 1
Multiple edge 2 => 3 with multiplicity 1

我注意到GraphIO.jl中有相关实现代码,但无法理解其逻辑,希望得到帮助。

内容的提问来源于stack exchange,提问作者A. T

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 21:48:27