The Parser class Main class for network file parsing and loading Supports GraphML, Pajek, Adjacency, Graphviz, UCINET, EdgeLists etc. More...

#include <parser.h>

+ Inheritance diagram for Parser:
+ Collaboration diagram for Parser:

Signals

void addRelation (const QString &relName, const bool &changeRelation=false)
 
void relationSet (int)
 
void createNode (const int &num, const int &size, const QString &color, const QString &numColor, const int &numSize, const QString &label, const QString &lColor, const int &lSize, const QPointF &p, const QString &shape, const QString &iconPath=QString::null, const bool &signalMW=false)
 
void createNodeAtPosRandom (const bool &signalMW=false)
 
void createNodeAtPosRandomWithLabel (const int &num, const QString &label, const bool &signalMW=false)
 
void edgeCreate (const int &source, const int &target, const qreal &weight, const QString &color, const int &edgeDirType, const bool &arrows, const bool &bezier, const QString &edgeLabel=QString::null, const bool &signalMW=false)
 
void networkFileLoaded (int fileType, QString fileName, QString netName, int totalNodes, int totalLinks, int edgeDirType, const QString &message=QString::null)
 
void removeDummyNode (int)
 
void finished (QString)
 

Public Member Functions

 Parser ()
 
 ~Parser ()
 
void load (const QString fn, const QString codec, const int iNS, const QString iNC, const QString iNSh, const QString iNNC, const int iNNS, const QString iNLC, const int iNLS, const QString iEC, const int w, const int h, const int format, const int sm_mode, const QString delim=QString::null)
 Loads the network calling one of the load* methods. More...
 
bool loadPajek ()
 
bool loadAdjacency ()
 Tries to load the file as adjacency sociomatrix-formatted. If not it returns -1. More...
 
bool loadDot ()
 
bool loadGraphML ()
 Tries to load a file as GraphML (not GML) formatted network. If not GraphML, it returns false. More...
 
bool loadGML ()
 
bool loadGW ()
 
bool loadDL ()
 
bool readDLKeywords (QStringList &strList, int &N, int &NM, int &NR, int &NC, bool &fullmatrixFormat, bool &edgelist1Format)
 
bool loadEdgeListSimple (const QString &delimiter)
 
bool loadEdgeListWeighed (const QString &delimiter)
 A method to load a weighted edge list formatted file. More...
 
bool loadTwoModeSociomatrix ()
 
void readDotProperties (QString str, qreal &, QString &label, QString &shape, QString &color, QString &fontName, QString &fontColor)
 
bool readGraphML (QXmlStreamReader &)
 Checks the xml token name and calls the appropriate function. Called from loadGraphML. More...
 
void readGraphMLElementGraph (QXmlStreamReader &)
 Reads a graph definition Called at Graph element. More...
 
void readGraphMLElementNode (QXmlStreamReader &)
 
void endGraphMLElementNode (QXmlStreamReader &)
 
void readGraphMLElementEdge (QXmlStreamAttributes &)
 
void endGraphMLElementEdge (QXmlStreamReader &)
 
void readGraphMLElementData (QXmlStreamReader &)
 Reads data for edges and nodes called at a data element (usually nested inside a node or an edge element) More...
 
void readGraphMLElementUnknown (QXmlStreamReader &)
 
void readGraphMLElementKey (QXmlStreamAttributes &)
 
bool xmlStreamHasAttribute (QXmlStreamAttributes &, QString) const
 
void readGraphMLElementDefaultValue (QXmlStreamReader &)
 Reads default key values Called at a default element (usually nested inside key element) More...
 
void readGraphMLElementNodeGraphics (QXmlStreamReader &)
 
void readGraphMLElementEdgeGraphics (QXmlStreamReader &)
 
void createMissingNodeEdges ()
 
bool isComment (QString str)
 
void createRandomNodes (const int &fixedNum=1, const QString &label=QString::null, const int &newNodes=1)
 Parser::createRandomNodes. More...
 
void loadFileError (const QString &errorMessage)
 Parser::loadFileError. More...
 

Private Attributes

QHash< QString, int > nodeHash
 
QHash< QString, QString > keyFor
 
QHash< QString, QString > keyName
 
QHash< QString, QString > keyType
 
QHash< QString, QString > keyDefaultValue
 
QHash< QString, QString > edgesMissingNodesHash
 
QStringList edgeMissingNodesList
 
QStringList edgeMissingNodesListData
 
QStringList relationsList
 
QMultiMap< int, int > firstModeMultiMap
 
QMultiMap< int, int > secondModeMultiMap
 
QXmlStreamReader * xml
 
QString fileName
 
QString fileDirPath
 
QString userSelectedCodecName
 
QString networkName
 
QString initNodeColor
 
QString initNodeShape
 
QString initNodeCustomIcon
 
QString initNodeNumberColor
 
QString initNodeLabelColor
 
QString initEdgeColor
 
QString initEdgeLabel
 
QString delimiter
 
QString errorMessage
 
QString nodeColor
 
QString edgeColor
 
QString edgeType
 
QString nodeShape
 
QString nodeLabel
 
QString edgeLabel
 
QString nodeIconPath
 
QString nodeNumberColor
 
QString nodeLabelColor
 
QString key_id
 
QString key_value
 
QString key_name
 
QString key_what
 
QString key_type
 
QString node_id
 
QString edge_id
 
QString edge_source
 
QString edge_target
 
QString edge_weight
 
QString edge_directed
 
int gwWidth
 
int gwHeight
 
int totalLinks
 
int totalNodes
 
int fileFormat
 
int two_sm_mode
 
int edgeDirType
 
int initNodeSize
 
int initNodeNumberSize
 
int nodeNumberSize
 
int initNodeLabelSize
 
int nodeLabelSize
 
int source
 
int target
 
int nodeSize
 
qreal initEdgeWeight
 
qreal edgeWeight
 
qreal arrowSize
 
qreal bez_p1_x
 
qreal bez_p1_y
 
qreal bez_p2_x
 
qreal bez_p2_y
 
bool missingNode
 
bool arrows
 
bool bezier
 
bool conv_OK
 
bool bool_key
 
bool bool_node
 
bool bool_edge
 
bool fileContainsNodeColors
 
bool fileContainsNodeCoords
 
bool fileContainsLinkColors
 
bool fileContainsLinkLabels
 
double randX
 
double randY
 

Detailed Description

The Parser class Main class for network file parsing and loading Supports GraphML, Pajek, Adjacency, Graphviz, UCINET, EdgeLists etc.

Constructor & Destructor Documentation

◆ Parser()

Parser::Parser ( )

◆ ~Parser()

Parser::~Parser ( )

Member Function Documentation

◆ addRelation

void Parser::addRelation ( const QString &  relName,
const bool &  changeRelation = false 
)
signal

◆ createMissingNodeEdges()

void Parser::createMissingNodeEdges ( )

◆ createNode

void Parser::createNode ( const int &  num,
const int &  size,
const QString &  color,
const QString &  numColor,
const int &  numSize,
const QString &  label,
const QString &  lColor,
const int &  lSize,
const QPointF &  p,
const QString &  shape,
const QString &  iconPath = QString::null,
const bool &  signalMW = false 
)
signal

◆ createNodeAtPosRandom

void Parser::createNodeAtPosRandom ( const bool &  signalMW = false)
signal

◆ createNodeAtPosRandomWithLabel

void Parser::createNodeAtPosRandomWithLabel ( const int &  num,
const QString &  label,
const bool &  signalMW = false 
)
signal

◆ createRandomNodes()

void Parser::createRandomNodes ( const int &  fixedNum = 1,
const QString &  label = QString::null,
const int &  newNodes = 1 
)

Parser::createRandomNodes.

Parameters
fixedNum
label
newNodesCreates either a new node numbered fixedNum or newNodes nodes numbered from 1 to to newNodes

◆ edgeCreate

void Parser::edgeCreate ( const int &  source,
const int &  target,
const qreal &  weight,
const QString &  color,
const int &  edgeDirType,
const bool &  arrows,
const bool &  bezier,
const QString &  edgeLabel = QString::null,
const bool &  signalMW = false 
)
signal

◆ endGraphMLElementEdge()

void Parser::endGraphMLElementEdge ( QXmlStreamReader &  xml)

◆ endGraphMLElementNode()

void Parser::endGraphMLElementNode ( QXmlStreamReader &  xml)

◆ finished

void Parser::finished ( QString  )
signal

◆ isComment()

bool Parser::isComment ( QString  str)

◆ load()

void Parser::load ( const QString  fn,
const QString  codec,
const int  iNS,
const QString  iNC,
const QString  iNSh,
const QString  iNNC,
const int  iNNS,
const QString  iNLC,
const int  iNLS,
const QString  iEC,
const int  w,
const int  h,
const int  format,
const int  sm_mode,
const QString  delim = QString::null 
)

Loads the network calling one of the load* methods.

◆ loadAdjacency()

bool Parser::loadAdjacency ( )

Tries to load the file as adjacency sociomatrix-formatted. If not it returns -1.

Returns
bool

◆ loadDL()

bool Parser::loadDL ( )

Tries to load a file as DL-formatted network (UCINET) If not it returns -1

◆ loadDot()

bool Parser::loadDot ( )

Tries to load the file as Dot (Graphviz) formatted network. If not it returns -1

◆ loadEdgeListSimple()

bool Parser::loadEdgeListSimple ( const QString &  delimiter)

◆ loadEdgeListWeighed()

bool Parser::loadEdgeListWeighed ( const QString &  delimiter)

A method to load a weighted edge list formatted file.

Parameters
delimiter
Returns
This method can read and parse edgelist formated files where edge source and target are either named with numbers or with labels That is the following formats can be parsed:

edgelist with node numbers

1 2 1 1 3 2 1 6 2 1 8 2 ...

edgelist with node labels

actor1 actor2 1 actor2 actor4 2 actor1 actor3 1 actorX actorY 3 name othername 1 othername somename 2 ....

◆ loadFileError()

void Parser::loadFileError ( const QString &  errorMessage)

Parser::loadFileError.

Parameters
errorMessageCalled when some Parser method cannot read or parse correctly a file. It informs the Graph and then MW with an error message

◆ loadGML()

bool Parser::loadGML ( )

Tries to load a file as GML formatted network. If not it returns -1

◆ loadGraphML()

bool Parser::loadGraphML ( )

Tries to load a file as GraphML (not GML) formatted network. If not GraphML, it returns false.

Returns

◆ loadGW()

bool Parser::loadGW ( )

◆ loadPajek()

bool Parser::loadPajek ( )

Tries to load the file as Pajek-formatted network. If not it returns -1

SPLIT EACH LINE (ON EMPTY SPACE CHARACTERS) IN SEVERAL ELEMENTS

READING NODES

NODELABEL

NODESHAPE: There are five possible .

NODECOLORS

READ NODE COORDINATES

START NODE CREATION

EDGES

ARCS

ARCSlist

matrix

◆ loadTwoModeSociomatrix()

bool Parser::loadTwoModeSociomatrix ( )

Tries to load the file as two-mode sociomatrix. If not it returns -1

◆ networkFileLoaded

void Parser::networkFileLoaded ( int  fileType,
QString  fileName,
QString  netName,
int  totalNodes,
int  totalLinks,
int  edgeDirType,
const QString &  message = QString::null 
)
signal

◆ readDLKeywords()

bool Parser::readDLKeywords ( QStringList &  strList,
int &  N,
int &  NM,
int &  NR,
int &  NC,
bool &  fullmatrixFormat,
bool &  edgelist1Format 
)

◆ readDotProperties()

void Parser::readDotProperties ( QString  str,
qreal &  nValue,
QString &  label,
QString &  shape,
QString &  color,
QString &  fontName,
QString &  fontColor 
)

◆ readGraphML()

bool Parser::readGraphML ( QXmlStreamReader &  xml)

Checks the xml token name and calls the appropriate function. Called from loadGraphML.

Parameters
xml
Returns

◆ readGraphMLElementData()

void Parser::readGraphMLElementData ( QXmlStreamReader &  xml)

Reads data for edges and nodes called at a data element (usually nested inside a node or an edge element)

Parameters
xml

◆ readGraphMLElementDefaultValue()

void Parser::readGraphMLElementDefaultValue ( QXmlStreamReader &  xml)

Reads default key values Called at a default element (usually nested inside key element)

Parameters
xml

◆ readGraphMLElementEdge()

void Parser::readGraphMLElementEdge ( QXmlStreamAttributes &  xmlStreamAttr)

◆ readGraphMLElementEdgeGraphics()

void Parser::readGraphMLElementEdgeGraphics ( QXmlStreamReader &  xml)

◆ readGraphMLElementGraph()

void Parser::readGraphMLElementGraph ( QXmlStreamReader &  xml)

Reads a graph definition Called at Graph element.

Parameters
xml

◆ readGraphMLElementKey()

void Parser::readGraphMLElementKey ( QXmlStreamAttributes &  xmlStreamAttr)

◆ readGraphMLElementNode()

void Parser::readGraphMLElementNode ( QXmlStreamReader &  xml)

◆ readGraphMLElementNodeGraphics()

void Parser::readGraphMLElementNodeGraphics ( QXmlStreamReader &  xml)

Reads node graphics data and properties: label, color, shape, size, coordinates, etc.

◆ readGraphMLElementUnknown()

void Parser::readGraphMLElementUnknown ( QXmlStreamReader &  xml)

◆ relationSet

void Parser::relationSet ( int  )
signal

◆ removeDummyNode

void Parser::removeDummyNode ( int  )
signal

◆ xmlStreamHasAttribute()

bool Parser::xmlStreamHasAttribute ( QXmlStreamAttributes &  xmlStreamAttr,
QString  str 
) const

Member Data Documentation

◆ arrows

bool Parser::arrows
private

◆ arrowSize

qreal Parser::arrowSize
private

◆ bez_p1_x

qreal Parser::bez_p1_x
private

◆ bez_p1_y

qreal Parser::bez_p1_y
private

◆ bez_p2_x

qreal Parser::bez_p2_x
private

◆ bez_p2_y

qreal Parser::bez_p2_y
private

◆ bezier

bool Parser::bezier
private

◆ bool_edge

bool Parser::bool_edge
private

◆ bool_key

bool Parser::bool_key
private

◆ bool_node

bool Parser::bool_node
private

◆ conv_OK

bool Parser::conv_OK
private

◆ delimiter

QString Parser::delimiter
private

◆ edge_directed

QString Parser::edge_directed
private

◆ edge_id

QString Parser::edge_id
private

◆ edge_source

QString Parser::edge_source
private

◆ edge_target

QString Parser::edge_target
private

◆ edge_weight

QString Parser::edge_weight
private

◆ edgeColor

QString Parser::edgeColor
private

◆ edgeDirType

int Parser::edgeDirType
private

◆ edgeLabel

QString Parser::edgeLabel
private

◆ edgeMissingNodesList

QStringList Parser::edgeMissingNodesList
private

◆ edgeMissingNodesListData

QStringList Parser::edgeMissingNodesListData
private

◆ edgesMissingNodesHash

QHash<QString, QString> Parser::edgesMissingNodesHash
private

◆ edgeType

QString Parser::edgeType
private

◆ edgeWeight

qreal Parser::edgeWeight
private

◆ errorMessage

QString Parser::errorMessage
private

◆ fileContainsLinkColors

bool Parser::fileContainsLinkColors
private

◆ fileContainsLinkLabels

bool Parser::fileContainsLinkLabels
private

◆ fileContainsNodeColors

bool Parser::fileContainsNodeColors
private

◆ fileContainsNodeCoords

bool Parser::fileContainsNodeCoords
private

◆ fileDirPath

QString Parser::fileDirPath
private

◆ fileFormat

int Parser::fileFormat
private

◆ fileName

QString Parser::fileName
private

◆ firstModeMultiMap

QMultiMap<int, int> Parser::firstModeMultiMap
private

◆ gwHeight

int Parser::gwHeight
private

◆ gwWidth

int Parser::gwWidth
private

◆ initEdgeColor

QString Parser::initEdgeColor
private

◆ initEdgeLabel

QString Parser::initEdgeLabel
private

◆ initEdgeWeight

qreal Parser::initEdgeWeight
private

◆ initNodeColor

QString Parser::initNodeColor
private

◆ initNodeCustomIcon

QString Parser::initNodeCustomIcon
private

◆ initNodeLabelColor

QString Parser::initNodeLabelColor
private

◆ initNodeLabelSize

int Parser::initNodeLabelSize
private

◆ initNodeNumberColor

QString Parser::initNodeNumberColor
private

◆ initNodeNumberSize

int Parser::initNodeNumberSize
private

◆ initNodeShape

QString Parser::initNodeShape
private

◆ initNodeSize

int Parser::initNodeSize
private

◆ key_id

QString Parser::key_id
private

◆ key_name

QString Parser::key_name
private

◆ key_type

QString Parser::key_type
private

◆ key_value

QString Parser::key_value
private

◆ key_what

QString Parser::key_what
private

◆ keyDefaultValue

QHash<QString, QString> Parser::keyDefaultValue
private

◆ keyFor

QHash<QString, QString> Parser::keyFor
private

◆ keyName

QHash<QString, QString> Parser::keyName
private

◆ keyType

QHash<QString, QString> Parser::keyType
private

◆ missingNode

bool Parser::missingNode
private

◆ networkName

QString Parser::networkName
private

◆ node_id

QString Parser::node_id
private

◆ nodeColor

QString Parser::nodeColor
private

◆ nodeHash

QHash<QString, int> Parser::nodeHash
private

◆ nodeIconPath

QString Parser::nodeIconPath
private

◆ nodeLabel

QString Parser::nodeLabel
private

◆ nodeLabelColor

QString Parser::nodeLabelColor
private

◆ nodeLabelSize

int Parser::nodeLabelSize
private

◆ nodeNumberColor

QString Parser::nodeNumberColor
private

◆ nodeNumberSize

int Parser::nodeNumberSize
private

◆ nodeShape

QString Parser::nodeShape
private

◆ nodeSize

int Parser::nodeSize
private

◆ randX

double Parser::randX
private

◆ randY

double Parser::randY
private

◆ relationsList

QStringList Parser::relationsList
private

◆ secondModeMultiMap

QMultiMap<int, int> Parser::secondModeMultiMap
private

◆ source

int Parser::source
private

◆ target

int Parser::target
private

◆ totalLinks

int Parser::totalLinks
private

◆ totalNodes

int Parser::totalNodes
private

◆ two_sm_mode

int Parser::two_sm_mode
private

◆ userSelectedCodecName

QString Parser::userSelectedCodecName
private

◆ xml

QXmlStreamReader* Parser::xml
private

The documentation for this class was generated from the following files: