![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/xuanbo/graph
图,邻接矩阵实现
顶点、边
动态扩容
初始化10个顶点,每次扩容增加10
DAG(有向无环图)检测
基于深度遍历算法
遍历DAG
适合基于DAG的任务流,依次执行的场景
优势,不需要起止节点,节点顺序执行,任务等待所有前置节点执行完再执行
不足,存在并行跨层次等待问题。
package main
import (
"fmt"
"github.com/xuanbo/graph"
)
func main() {
// 创建
g := graph.NewGraph()
// 添加顶点
g.AddVertex("a")
g.AddVertex("b")
g.AddVertex("c")
g.AddVertex("d")
g.AddVertex("e")
g.AddVertex("f")
g.AddVertex("g")
g.AddVertex("h")
g.AddVertex("i")
g.AddVertex("j")
// 默认初始化10个顶点,此处扩容一次
g.AddVertex("k")
// 添加边
g.AddEdge("a", "b")
g.AddEdge("a", "k")
g.AddEdge("b", "c")
g.AddEdge("b", "k")
g.AddEdge("c", "d")
g.AddEdge("c", "g")
g.AddEdge("c", "k")
// isDAG
// 输出:false
fmt.Printf("isDAG: %v\n", g.IsDAG())
// 遍历DAG
// 输出:a e f h i j b c d g k
fmt.Printf("walk: %v\n", g.ForeachDAG())
}
注意,底层实现为线程不安全
研究基于DAG的任务流系统有感~
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.