![](/img/trans.png)
[英]Julia / Graphs.jl : creating graph using graph() and arguments
[英]Julia Graphs.jl ExVertex method not matching arguments
我正在嘗試創建頂點,並且在Graphs.jl文檔中找到了一些示例,但我不知道為什么它不起作用。
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
在我們的機器中不同?”
為了得到正確的答案,我們必須查看Julia手冊中有關整數類型的部分:
整數文字的默認類型取決於目標系統是32位體系結構還是64位體系結構:
# 32-bit system: julia> typeof(1) Int32
# 64-bit system: julia> typeof(1) Int64
Julia內部變量WORD_SIZE指示目標系統是> 32位還是64位。
# 32-bit system: julia> WORD_SIZE 32
# 64-bit system: julia> WORD_SIZE 64
提示:您可以像這樣將類型1
為UInt32
: V1 = ExVertex(1%UInt32, "V1") # => vertex [1] "V1"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.