C# Class Smrf.NodeXL.Adapters.PajekGraphAdapter

Converts a graph to and from a subset of the Pajek format.
This class supports only a subset of the Pajek format, which is roughly described in the Pajek Reference Manual at http://vlado.fmf.uni-lj.si/pub/networks/pajek/doc/pajekman.pdf.

This is the supported subset:

*vertices N 1 "vertex 1 name" [x y z] 2 "vertex 2 name" [x y z] ... N "vertex N name" [x y z] *edges Vi Vj weight Vm Vn weight ... *edgeslist Vi Vj Vk ... Vm Vn ... ... *arcs Vi Vj weight Vm Vn weight ... *arcslist Vi Vj Vk ... Vm Vn ... ...

The delimiter is any combination of spaces and tabs.

All sections are optional. If there is at least one section, there must be one and only one *vertices section and it must be the first section. If edges are specified with *edges and *edgeslist sections only, the graph is considered undirected. If edges are specified with *arcs and *arcslist sections only, the graph is considered directed. If there are both undirected and directed edges, the graph is considered mixed.

Empty lines are ignored. Lines starting with slash-asterisk are considered comments and are skipped.

Everything is case-insensitive except the vertex names.

Inheritance: GraphAdapterBase, IGraphAdapter
Show file Open project: 2014-sed-team3/term-project Class Usage Examples

Protected Properties

Property Type Description
StreamEncoding System.Text.Encoding
m_eCurrentSection Sections
m_oVertexRegex System.Text.RegularExpressions.Regex

Public Methods

Method Description
AssertValid ( ) : void
PajekGraphAdapter ( ) : System

Initializes a new instance of the PajekGraphAdapter class.

Protected Methods

Method Description
AddEdgeToGraph ( PajekEdgeData oEdgeData, IEdgeCollection oEdges, IVertex aoVertices, System.Boolean bDirected ) : void
CheckVertexNumber ( Int32 iVertexNumber, String sLine, Int32 iLineNumber, Int32 iVertices ) : void
CreateGraph ( IVertex aoVertices, List oUndirectedEdgeData, List oDirectedEdgeData ) : IGraph
GetSupportedDirectedness ( System.Boolean &supportsDirected, System.Boolean &supportsUndirected, System.Boolean &supportsMixed ) : void
IsValidEdgeSection ( String sLine, Int32 iLineNumber, String sSectionName, IVertex aoVertices ) : System.Boolean
LoadGraphCore ( Stream stream ) : IGraph
ParseEdge ( String sLine, Int32 iLineNumber, Int32 iVertices, List oEdgeData ) : void
ParseEdgeList ( String sLine, Int32 iLineNumber, Int32 iVertices, List oEdgeData ) : void
ParseVertex ( String sLine, Int32 iLineNumber, IVertex aoVertices, Int32 &iVerticesParsed ) : void
SaveGraphCore ( IGraph graph, Stream stream ) : void
SplitLine ( String sLine ) : String[]
WriteEdge ( IEdge oEdge, Int32>.Dictionary oVertexIDToNumber, StreamWriter oStreamWriter ) : void

Method Details

AddEdgeToGraph() protected method

protected AddEdgeToGraph ( PajekEdgeData oEdgeData, IEdgeCollection oEdges, IVertex aoVertices, System.Boolean bDirected ) : void
oEdgeData PajekEdgeData
oEdges IEdgeCollection
aoVertices IVertex
bDirected System.Boolean
return void

AssertValid() public method

public AssertValid ( ) : void
return void

CheckVertexNumber() protected method

protected CheckVertexNumber ( Int32 iVertexNumber, String sLine, Int32 iLineNumber, Int32 iVertices ) : void
iVertexNumber System.Int32
sLine String
iLineNumber System.Int32
iVertices System.Int32
return void

CreateGraph() protected method

protected CreateGraph ( IVertex aoVertices, List oUndirectedEdgeData, List oDirectedEdgeData ) : IGraph
aoVertices IVertex
oUndirectedEdgeData List
oDirectedEdgeData List
return IGraph

GetSupportedDirectedness() protected method

protected GetSupportedDirectedness ( System.Boolean &supportsDirected, System.Boolean &supportsUndirected, System.Boolean &supportsMixed ) : void
supportsDirected System.Boolean
supportsUndirected System.Boolean
supportsMixed System.Boolean
return void

IsValidEdgeSection() protected method

protected IsValidEdgeSection ( String sLine, Int32 iLineNumber, String sSectionName, IVertex aoVertices ) : System.Boolean
sLine String
iLineNumber System.Int32
sSectionName String
aoVertices IVertex
return System.Boolean

LoadGraphCore() protected method

protected LoadGraphCore ( Stream stream ) : IGraph
stream Stream
return IGraph

PajekGraphAdapter() public method

Initializes a new instance of the PajekGraphAdapter class.
public PajekGraphAdapter ( ) : System
return System

ParseEdge() protected method

protected ParseEdge ( String sLine, Int32 iLineNumber, Int32 iVertices, List oEdgeData ) : void
sLine String
iLineNumber System.Int32
iVertices System.Int32
oEdgeData List
return void

ParseEdgeList() protected method

protected ParseEdgeList ( String sLine, Int32 iLineNumber, Int32 iVertices, List oEdgeData ) : void
sLine String
iLineNumber System.Int32
iVertices System.Int32
oEdgeData List
return void

ParseVertex() protected method

protected ParseVertex ( String sLine, Int32 iLineNumber, IVertex aoVertices, Int32 &iVerticesParsed ) : void
sLine String
iLineNumber System.Int32
aoVertices IVertex
iVerticesParsed System.Int32
return void

SaveGraphCore() protected method

protected SaveGraphCore ( IGraph graph, Stream stream ) : void
graph IGraph
stream Stream
return void

SplitLine() protected method

protected SplitLine ( String sLine ) : String[]
sLine String
return String[]

WriteEdge() protected method

protected WriteEdge ( IEdge oEdge, Int32>.Dictionary oVertexIDToNumber, StreamWriter oStreamWriter ) : void
oEdge IEdge
oVertexIDToNumber Int32>.Dictionary
oStreamWriter System.IO.StreamWriter
return void

Property Details

StreamEncoding protected static property

protected static Encoding,System.Text StreamEncoding
return System.Text.Encoding

m_eCurrentSection protected property

protected Sections m_eCurrentSection
return Sections

m_oVertexRegex protected property

protected Regex,System.Text.RegularExpressions m_oVertexRegex
return System.Text.RegularExpressions.Regex