我想創建頂點,我發現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