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 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 float &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, bool edgeDirType, const QString &message=QString::null)
 
void removeDummyNode (int)
 
void finished (QString)
 

Public Member Functions

 Parser (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)
 
 ~Parser ()
 
void run ()
 
bool loadPajek ()
 
bool loadAdjacency ()
 
bool loadDot ()
 
bool loadGraphML ()
 
bool loadGML ()
 
bool loadGW ()
 
bool loadDL ()
 
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, float &, QString &label, QString &shape, QString &color, QString &fontName, QString &fontColor)
 
bool readGraphML (QXmlStreamReader &)
 
void readGraphMLElementGraph (QXmlStreamReader &)
 
void readGraphMLElementNode (QXmlStreamReader &)
 
void endGraphMLElementNode (QXmlStreamReader &)
 
void readGraphMLElementEdge (QXmlStreamAttributes &)
 
void endGraphMLElementEdge (QXmlStreamReader &)
 
void readGraphMLElementData (QXmlStreamReader &)
 
void readGraphMLElementUnknown (QXmlStreamReader &)
 
void readGraphMLElementKey (QXmlStreamAttributes &)
 
bool xmlStreamHasAttribute (QXmlStreamAttributes &, QString) const
 
void readGraphMLElementDefaultValue (QXmlStreamReader &)
 
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 userSelectedCodecName
 
QString networkName
 
QString initNodeColor
 
QString initEdgeColor
 
QString initNodeShape
 
QString initNodeNumberColor
 
QString initNodeLabelColor
 
QString initEdgeLabel
 
QString delimiter
 
QString errorMessage
 
QString nodeColor
 
QString edgeColor
 
QString edgeType
 
QString nodeShape
 
QString nodeLabel
 
QString edgeLabel
 
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
 
float initEdgeWeight
 
float edgeWeight
 
float arrowSize
 
float bez_p1_x
 
float bez_p1_y
 
float bez_p2_x
 
float 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 ( 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 
)
Parser::~Parser ( )

Member Function Documentation

void Parser::addRelation ( const QString &  relName,
const bool &  changeRelation = false 
)
signal
void Parser::createMissingNodeEdges ( )
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 bool &  signalMW = false 
)
signal
void Parser::createNodeAtPosRandom ( const bool &  signalMW = false)
signal
void Parser::createNodeAtPosRandomWithLabel ( const int &  num,
const QString &  label,
const bool &  signalMW = false 
)
signal
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
void Parser::edgeCreate ( const int &  source,
const int &  target,
const float &  weight,
const QString &  color,
const int &  edgeDirType,
const bool &  arrows,
const bool &  bezier,
const QString &  edgeLabel = QString::null,
const bool &  signalMW = false 
)
signal
void Parser::endGraphMLElementEdge ( QXmlStreamReader &  xml)
void Parser::endGraphMLElementNode ( QXmlStreamReader &  xml)
void Parser::finished ( QString  )
signal
bool Parser::isComment ( QString  str)
bool Parser::loadAdjacency ( )

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

bool Parser::loadDL ( )

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

bool Parser::loadDot ( )

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

bool Parser::loadEdgeListSimple ( const QString &  delimiter)
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 ....

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
bool Parser::loadGML ( )

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

bool Parser::loadGraphML ( )

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

bool Parser::loadGW ( )
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

bool Parser::loadTwoModeSociomatrix ( )

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

void Parser::networkFileLoaded ( int  fileType,
QString  fileName,
QString  netName,
int  totalNodes,
int  totalLinks,
bool  edgeDirType,
const QString &  message = QString::null 
)
signal
void Parser::readDotProperties ( QString  str,
float &  nValue,
QString &  label,
QString &  shape,
QString &  color,
QString &  fontName,
QString &  fontColor 
)
bool Parser::readGraphML ( QXmlStreamReader &  xml)
void Parser::readGraphMLElementData ( QXmlStreamReader &  xml)
void Parser::readGraphMLElementDefaultValue ( QXmlStreamReader &  xml)
void Parser::readGraphMLElementEdge ( QXmlStreamAttributes &  xmlStreamAttr)
void Parser::readGraphMLElementEdgeGraphics ( QXmlStreamReader &  xml)
void Parser::readGraphMLElementGraph ( QXmlStreamReader &  xml)
void Parser::readGraphMLElementKey ( QXmlStreamAttributes &  xmlStreamAttr)
void Parser::readGraphMLElementNode ( QXmlStreamReader &  xml)
void Parser::readGraphMLElementNodeGraphics ( QXmlStreamReader &  xml)

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

void Parser::readGraphMLElementUnknown ( QXmlStreamReader &  xml)
void Parser::relationSet ( int  )
signal
void Parser::removeDummyNode ( int  )
signal
void Parser::run ( )

starts the new thread calling the load* methods

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

Member Data Documentation

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

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