当我开始编写PSGraph时,它开始作为一种方法来编写PowerShell中的GraphViz指令。 GraphViz的结构和语法严重影响了我在PSGraph中建立命令的影响。此版本发布了一些这些命令,并开始工作,而不是转换命令。我1.2的焦点是使子图更容易使用。

指数

匿名图

值得一提的第一个变更是PSGraph现在支持匿名或未命名的图形和子图。当我教其他人如何使用psgraph时,我将有一个这样的例子:

Graph g {
    Edge Home,Work1,Lunch,Work2,Home

    SubGraph 0 {
        Node Lunch
        Node Work1,Work2 @{label='Work'}
        Rank Work1,Work2
    }
} | Export-PSGraph -ShowGraph

I would always have to explain a few thing because I was exposing GraphViz requirements in my DSL. Why do I have to name the graph? Graph g Why do I have to name my SubGraph? SubGraph 0. I was also under the misunderstanding that the subgraph name needed to be numeric. Well, Just because GraphViz requires these to be named, PSGraph does not need to have the same requirement.

从此版本开始,您不必命名您的图表。如果您确实命名它们,则支持字符串。这是一个有效的Psgraph:

图{
    Edge Home,Work1,Lunch,Work2,Home

    SubGraph {
        Node Lunch
        Node Work1,Work2 @{label='Work'}
        Rank Work1,Work2
    }
}

所以你不必再命名它们了。 Psgraph将继续前进,给他们一个名字。

边缘到子图

This was more challenging because it isn’t really supported the way you would expect in the DOT language. I decided that I wanted a simple and intuitive syntax for this. We already give our subgraphs names. Why not just allow Edge to create edges to subgraphs instead of just nodes. This is what I ended up with.

图{
    SubGraph Source {
        Node Inside
    }
    Node Outside
    Edge -From Source -To Outside
}

我对这种变化感到非常兴奋,即使很难说我甚至做任何事情。我能够把它丢弃到psgraph dsl中,就好像它是从头到尾的。这是你必须做的旧方式:

Graph g @{compound='true'} {
    SubGraph 0 {
        Node Inside
        Source @{label="";style="invis";shape="point";}
    }
    Node Outside
    Edge -From Source -To Outside @{ltail='cluster_0'}
}

您必须将隐藏的节点放入子图,然后使其优势更换为此。然后,您必须添加所有其他属性以确保它看起来是您想要的方式。我还在做所有那种,但现在它发生在封面之下,所以你不必考虑它。

node -Ranked.

The other change that made it into this release was the addition of a -Ranked switch on the Node command. A common pattern that I had was to add a set of nodes and then rank them on the next line.

图{ Node -Ranked A,B,C }

The Rank command still exists so none of your old graphs should break.

在结束时

我正在使用PSGraph的第二个模块,我已经使用了这些新功能。如果您使用的是Psgraph并且喜欢这些更改,请将推文放电让我知道。