Skip to content

Commit 771a849

Browse files
committed
updated documentation
1 parent c878586 commit 771a849

16 files changed

Lines changed: 1309 additions & 186 deletions

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,39 @@ The original goal was to **analyse dependencies** in IaC workloads, but the modu
3636

3737
---
3838

39+
## Examples Index
40+
41+
Jump straight to focused, copy‑paste friendly examples for each major task. All examples assume the module is imported and use concise variable names.
42+
43+
### Graph Construction & Mutation
44+
* `New-Graph` – create an empty bidirectional graph (`docs/New-Graph.md`)
45+
* `New-AdjacencyGraph` – create an adjacency-list backed graph (`docs/New-AdjacencyGraph.md`)
46+
* `Add-Vertex` – add (or dedupe) vertices (`docs/Add-Vertex.md`)
47+
* `Add-Edge` – add directed edges with optional tag (`docs/Add-Edge.md`)
48+
* `Import-Graph` – load GraphML into a new graph (`docs/Import-Graph.md`)
49+
* `Export-Graph` – Graphviz / GraphML / MSAGL / Vega export (`docs/Export-Graph.md`)
50+
51+
### Graph Query & Analysis
52+
* `Get-GraphPath` – shortest path (Dijkstra) between two vertices (`docs/Get-GraphPath.md`)
53+
* `Test-GraphPath` – fast reachability boolean (`docs/Test-GraphPath.md`)
54+
* `Get-InEdge` / `Get-OutEdge` – incoming / outgoing edge enumeration (`docs/Get-InEdge.md`, `docs/Get-OutEdge.md`)
55+
* `Get-GraphDistanceVector` – root-based distance levels (`docs/Get-GraphDistanceVector.md`)
56+
57+
### Design Structure Matrix (DSM)
58+
* `New-DSM` – wrap a graph as a DSM (`docs/New-DSM.md`)
59+
* `Start-DSMClustering` – cluster / partition with SA or graph-based algorithms (`docs/Start-DSMClustering.md`)
60+
* `Start-DSMSequencing` – reorder to expose sources / cycles / sinks (`docs/Start-DSMSequencing.md`)
61+
* `Export-DSM` – text / Vega matrix export (`docs/Export-DSM.md`)
62+
63+
### Typical End-to-End Flows
64+
* Build → Query: New-Graph → Add-Vertex / Add-Edge → Get-GraphPath / Get-InEdge
65+
* Import → Analyse → Export: Import-Graph → Get-GraphDistanceVector → Export-Graph
66+
* Graph → DSM Insight: New-Graph → Add-* → New-DSM → Start-DSMClustering / Start-DSMSequencing → Export-DSM
67+
68+
> Tip: Each linked doc contains multiple scenarios; skim the first example for the minimal pattern, then look for advanced sections (weights, tagging, configs).
69+
70+
---
71+
3972
## Quick install
4073

4174
```powershell

docs/Add-Edge.md

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,72 @@
11
---
22
external help file: PSGraph.dll-Help.xml
3-
online version:
3+
Module Name: PSGraph
4+
online version:
45
schema: 2.0.0
56
---
67

78
# Add-Edge
89

910
## SYNOPSIS
10-
Adds an edge between two vertexes into a graph
11+
Add a directed edge between two vertices (creating the vertices if they do not yet exist).
1112

1213
## SYNTAX
1314

1415
```
15-
Add-Edge -From <Object> -To <Object> -Graph <Object> [-Attribute <Object>] [<CommonParameters>]
16+
Add-Edge -From <PSObject> -To <PSObject>
17+
-Graph <QuikGraph.IMutableVertexAndEdgeListGraph`2[PSGraph.Model.PSVertex,PSGraph.Model.PSEdge]>
18+
[-Tag <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
1619
```
1720

1821
## DESCRIPTION
19-
Adds an edge between two vertexes into a graph
22+
Adds a directed edge From -> To into the supplied mutable graph. If either -From or -To is not
23+
already a PSGraph PSVertex it is wrapped in a new PSVertex whose Label is the object's ToString().
24+
If the vertices already exist (label equality) the existing instances are reused. An optional
25+
Tag value is stored on the created PSEdge (converted to string when present). The cmdlet does not
26+
emit a value; use the graph object to inspect results.
2027

2128
## EXAMPLES
2229

2330
### Example 1
24-
In this example new graph is created and stored in $g variable. Next line adds an edge from A to B into it. Vertexes A and B are automatically added to the graph. If vertexes are already in the graph they are used as source and target vertexes. In order for this to work vertex types has to be comparable.
31+
Create a graph and add an edge A -> B (vertices auto-created).
32+
```powershell
33+
$g = New-Graph
34+
Add-Edge -From A -To B -Graph $g
35+
$g.EdgeCount # 1
36+
```
2537

26-
```powershell code
27-
PS C:\> $g = New-Graph -Type AdjacencyGraph
28-
PS C:\> Add-Edge -From A -To B -Graph $g
38+
### Example 2
39+
Attach a tag to an edge.
40+
```powershell
41+
$g = New-Graph
42+
Add-Edge -From A -To B -Graph $g -Tag Dependency
43+
($g.Edges | Select-Object -First 1).Tag.Value # "Dependency"
2944
```
3045

3146
## PARAMETERS
3247

33-
### -Attribute
34-
Not used in current implementation
48+
### -From
49+
Source vertex (or arbitrary object which will be wrapped as a vertex) for the edge.
3550

3651
```yaml
37-
Type: Object
52+
Type: PSObject
3853
Parameter Sets: (All)
39-
Aliases:
54+
Aliases:
4055

41-
Required: False
56+
Required: True
4257
Position: Named
4358
Default value: None
4459
Accept pipeline input: False
4560
Accept wildcard characters: False
4661
```
4762
48-
### -From
49-
Source vertex to use for the edge
63+
### -Graph
64+
Graph instance receiving the edge. Must be a mutable, directed QuikGraph implementation.
5065
5166
```yaml
52-
Type: Object
67+
Type: QuikGraph.IMutableVertexAndEdgeListGraph`2[PSGraph.Model.PSVertex,PSGraph.Model.PSEdge]
5368
Parameter Sets: (All)
54-
Aliases:
69+
Aliases:
5570

5671
Required: True
5772
Position: Named
@@ -60,28 +75,28 @@ Accept pipeline input: False
6075
Accept wildcard characters: False
6176
```
6277
63-
### -Graph
64-
Graph to add vertexes and edges to
78+
### -Tag
79+
Optional label stored inside the created edge's Tag object (stringified).
6580
6681
```yaml
6782
Type: Object
6883
Parameter Sets: (All)
69-
Aliases:
84+
Aliases:
7085

71-
Required: True
86+
Required: False
7287
Position: Named
7388
Default value: None
7489
Accept pipeline input: False
7590
Accept wildcard characters: False
7691
```
7792
7893
### -To
79-
Target vertex to use for the edge
94+
Target vertex (or object to wrap) for the edge.
8095
8196
```yaml
82-
Type: Object
97+
Type: PSObject
8398
Parameter Sets: (All)
84-
Aliases:
99+
Aliases:
85100

86101
Required: True
87102
Position: Named
@@ -90,19 +105,32 @@ Accept pipeline input: False
90105
Accept wildcard characters: False
91106
```
92107
108+
### -ProgressAction
109+
Internal PowerShell progress preference (normally not used).
110+
111+
```yaml
112+
Type: ActionPreference
113+
Parameter Sets: (All)
114+
Aliases: proga
115+
116+
Required: False
117+
Position: Named
118+
Default value: None
119+
Accept pipeline input: False
120+
Accept wildcard characters: False
121+
```
122+
93123
### CommonParameters
94-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
124+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
95125
96126
## INPUTS
97127
98128
### None
99-
When addin edges library checks to see if there are such edges and vertices. If they are they are not added to the graph. Instead existing once are used.
100-
101129
## OUTPUTS
102130
103-
### System.Object
104-
131+
### None
105132
## NOTES
106133
107134
## RELATED LINKS
108-
135+
Add-Vertex
136+
New-Graph

docs/Add-Vertex.md

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,58 @@
11
---
22
external help file: PSGraph.dll-Help.xml
3-
online version:
3+
Module Name: PSGraph
4+
online version:
45
schema: 2.0.0
56
---
67

78
# Add-Vertex
89

910
## SYNOPSIS
10-
Command takes an object and adds it as a vertex to a graph
11+
Add a vertex to a graph (no-op if an equivalent vertex already exists).
1112

1213
## SYNTAX
1314

1415
```
15-
Add-Vertex -Vertex <Object> -Graph <Object> [<CommonParameters>]
16+
Add-Vertex -Vertex <PSObject>
17+
-Graph <QuikGraph.IMutableVertexAndEdgeListGraph`2[PSGraph.Model.PSVertex,PSGraph.Model.PSEdge]>
18+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
1619
```
1720

1821
## DESCRIPTION
19-
Command takes an object and adds it as a vertex to a graph. You must specify the graph to add the object to.
22+
Adds a vertex object into the provided graph. If you pass an existing PSVertex it is added
23+
directly; otherwise the object is wrapped in a new PSVertex whose Label is the object's ToString().
24+
Duplicate detection relies on PSVertex equality (label based) so calling multiple times with the
25+
same label will not create duplicates. The cmdlet writes no output; inspect the graph instance.
2026

2127
## EXAMPLES
2228

2329
### Example 1
24-
25-
In this example $ps variable contains a list of processes.
26-
This list is then converted into a set of Psgraph.PSGraphVertex objects and each of these objects then added to a graph $g as a vertex
27-
28-
```powershell code
29-
$ps = gwmi win32_process
30-
31-
class process : Psgraph.PSGraphVertex {
32-
[string]$ProcessName
33-
[int]$ProcessID
34-
[int]$ParentProcessId
35-
[string]get_UniqueKey() { return $this.ProcessID }
36-
}
37-
38-
$g = New-Graph -Type AdjacencyGraph
39-
40-
$ps | % {
41-
$p = [process]@{
42-
ProcessName = $_.ProcessName
43-
ProcessID = $_.ProcessID
44-
ParentProcessId = $_.ParentProcessId
45-
Label = $_.ProcessName
46-
}
47-
Add-Vertex -Vertex $p -Graph $g
48-
}
30+
Add three plain string vertices.
31+
```powershell
32+
$g = New-Graph
33+
Add-Vertex -Vertex A -Graph $g
34+
Add-Vertex -Vertex B -Graph $g
35+
Add-Vertex -Vertex C -Graph $g
36+
$g.VertexCount # 3
4937
```
5038

5139
### Example 2
52-
53-
In this example new graph class is derived from Psgraph.PSGraphVertex exported from the module. This type is used as a base type because it contains all neccessary metadata which is needed to export graph into the DOT language format. Exported file then can be used by graphviz utility to visualize the graph.
54-
55-
```powershell code
56-
class process : Psgraph.PSGraphVertex {
57-
[string]$ProcessName
58-
[int]$ProcessID
59-
[int]$ParentProcessId
60-
[string]get_UniqueKey() { return $this.ProcessID }
61-
}
40+
Add a pre-constructed PSVertex to preserve metadata.
41+
```powershell
42+
$g = New-Graph
43+
$v = [PSGraph.Model.PSVertex]::new("ServiceA")
44+
Add-Vertex -Vertex $v -Graph $g
6245
```
6346

6447
## PARAMETERS
6548

6649
### -Graph
67-
Takes a variable containing a graph instance
50+
Graph instance receiving the vertex.
6851

6952
```yaml
70-
Type: Object
53+
Type: QuikGraph.IMutableVertexAndEdgeListGraph`2[PSGraph.Model.PSVertex,PSGraph.Model.PSEdge]
7154
Parameter Sets: (All)
72-
Aliases:
55+
Aliases:
7356

7457
Required: True
7558
Position: Named
@@ -79,12 +62,12 @@ Accept wildcard characters: False
7962
```
8063
8164
### -Vertex
82-
Parameter takes an object as a vertex of a graph
65+
Object or PSVertex to add. Non-PSVertex objects are wrapped automatically.
8366
8467
```yaml
85-
Type: Object
68+
Type: PSObject
8669
Parameter Sets: (All)
87-
Aliases:
70+
Aliases:
8871

8972
Required: True
9073
Position: Named
@@ -93,20 +76,32 @@ Accept pipeline input: False
9376
Accept wildcard characters: False
9477
```
9578
79+
### -ProgressAction
80+
Internal PowerShell progress preference (not commonly used).
81+
82+
```yaml
83+
Type: ActionPreference
84+
Parameter Sets: (All)
85+
Aliases: proga
86+
87+
Required: False
88+
Position: Named
89+
Default value: None
90+
Accept pipeline input: False
91+
Accept wildcard characters: False
92+
```
93+
9694
### CommonParameters
97-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
95+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
9896
9997
## INPUTS
10098
10199
### None
102-
103100
## OUTPUTS
104101
105-
### System.Object
106-
102+
### None
107103
## NOTES
108-
When adding new vertecies, library checks to see if they are alreagy in the graph. In case they are a new vertex is not added. For the basic .NET types this type of comparison works by default. However if you use your custom type which stores some additional metadata you need to provide a special method to compare them, see Example 2 for reference.
109104
110105
## RELATED LINKS
111-
[New-Graph](https://github.com/eosfor/PSGraph/wiki/New-Graph)
112-
106+
Add-Edge
107+
New-Graph

0 commit comments

Comments
 (0)