我想创建顶点,我发现Graphs.jl文档中的一些例子,但我找不出它为什么不工作。Julia Graphs.jl ExVertex方法不匹配参数
using Graphs
V1 = ExVertex(1, "V1");
V1.attributes["size"] = 5.0
但它表示ExVertex没有匹配ExVertex(Int64,ASCIIString)的方法。任何帮助?
我想创建顶点,我发现Graphs.jl文档中的一些例子,但我找不出它为什么不工作。Julia Graphs.jl ExVertex方法不匹配参数
using Graphs
V1 = ExVertex(1, "V1");
V1.attributes["size"] = 5.0
但它表示ExVertex没有匹配ExVertex(Int64,ASCIIString)的方法。任何帮助?
首先让我检查参数类型ExVertex()
功能,使用?
命令得到的帮助:
help?> ExVertex
search: ExVertex
No documentation found.
Summary:
type Graphs.ExVertex <: Any
Fields:
index :: Int32
label :: UTF8String
attributes :: Dict{UTF8String,Any}
所以我的机器index
上必须Int32
,现在我们将检查的实际类型的1
:typeof(1) # => Int32
,因此,如果我叫你把它称为是功能,我就没有错误:
V1 = ExVertex(1, "V1") # => vertex [1] "V1"
这个测试提出了另一个问题:“为什么我们的机器号码1
的类型不同?”
得到的一定要检查有关integer types茱莉亚手册中的正确答案:
The default type for an integer literal depends on whether the target system has a 32-bit architecture or a 64-bit architecture:
# 32-bit system: julia> typeof(1) Int32
# 64-bit system: julia> typeof(1) Int64
The Julia internal variable WORD_SIZE indicates whether the target system is >32-bit or 64-bit.:
# 32-bit system: julia> WORD_SIZE 32
# 64-bit system: julia> WORD_SIZE 64
提示:您可以键入投1
为UInt32
这样的: V1 = ExVertex(1%UInt32, "V1") # => vertex [1] "V1"
我觉得这种类型的号码是没问题。后来我发布问题后,我试着这个'V1 = Graphs.ExVertex(1,“V1”)',它的工作原理。我认为它不能找到方法ExVertex,但我不知道为什么,因为我使用包Graph中的其他方法,它们的工作原理。 – user2938332