我有一個gxl文件,我想要找到它的所有末端節點(葉)並存儲每個末端節點名稱(在標籤節點中,名稱屬性)。 我意識到,在gxl文件中,末端節點是具有節點標籤並且沒有邊緣標籤的節點。Python:在gxl文件中找到末端節點(葉)
我想找到所有沒有任何邊緣的節點。
那麼我該怎麼做呢? 這裏是我的GXL文件樣本鏈接: https://gist.github.com/anonymous/61c1afd751214a0473fd62ee74a3b1d6
例如這裏節點ID 270是末端節點,因爲它沒有任何邊緣的標籤。 :
<node id="N_270">
<attr name="name">
<string>
android.content.Context
java.lang.String getString(int)
</string>
</attr>
</node>
<node id="N_271">
<attr name="name">
<string>android.view.ViewGroup
voidinit(android.content.Context,android.util.AttributeSet,int)
</string>
</attr>
</node>
<edge from="N_271" to="N_291" isdirected="true" id="N_271--N_291">
</edge>
請在您的問題的正文中提供一個小測試用例。 https://stackoverflow.com/help/mcve – jdv