6. NetMiner Script Function Reference
6. NetMiner Script Function Reference
2
Copyright and Trademarks
The information in this publication is provided for information only and is subject to change without notice. Cyram Inc.
assume no responsibility or liability for any loss or damage that may arise from the use of any information in this publication.
The software described in this book is furnished under license and may only be used or copied in accordance with the terms
of that license.
NetMiner is a registered trademark of Cyram Inc. CYRAM and CYRAM logo are registered trademarks of Cyram Inc.
Cyram Inc.
#904, U-Space 2B, 670, Daewangpangyo-ro, Bundang-gu, Seongnam-si, Gyeonggi-do, 13494,
South Korea
Tel: +82-31-739-8352
Fax: +82-31-739-8354
In order to reference NetMiner 4, please employ the following bold-faced reference, which is also found at NetMiner Menu:
“Help >> About NetMiner 4”.
Technical Support
The NetMiner Help file will guide you to use NetMiner 4. Simply press F1 function key or use NetMiner menu bar for
triggering Help feature.
Cyram is committed to provide a reliable, high-quality, yet easy-to-use product. If you have any problem of installing or
using NetMiner, please contact us by mail, phone and fax or preferably by email and World Wide Web.
Cyram Inc.
#904, U-Space 2B, 670, Daewangpangyo-ro, Bundang-gu, Seongnam-si, Gyeonggi-do, 13494,
South Korea
Tel: +82-31-739-8352
Fax: +82-31-739-8354
Email: [email protected] Web: http://www.netminer.com/
3
1
Data Handling
1.1 Project 10 1.5 Export __________ 39 __________
• openProject • openProject • createTextExporter • creater
• newProject • • createExcelExporter • cer
• saveProject • exportMainNodeSet • expt
• saveAsProject • exportSubNodeSet • exportS
• exportNetworkToMatrix • e
1.2 Workfile\ 13\ • exportNetworkToEdgeList • e
• selectWorkfile • s
• getWorkfileNames • g 1.6 Session ___________________ 45 _________________
• getCurrentWorkfileName • ge • createSession • c
• openSession • o
1.3 Dataset ___________________ 15 • closeSession • cl
• getMainAttributeNames • getM • close • close
• getSubAttributeNames • getSu • deleteSession • del
• getSubNodeSetNames • getSu • delete • delete
• get1modeNetworkNames • get1m • getSessionName • get
• get2modeNetworkNames • get2m • setSessionName • se
• getMainAttributeValues • getM • getFocusedSession • getF
• getSubAttributeValues • getSubA • run • run
• deleteMainAttribute • delete • saveOutputTables • save
• deleteSubAttribute • delet
• deleteNetwork • del 1.7 Query ___________________ 51
• createQuerySet • createQ
1.4 Import __________________ 22 • getQuerySet • getQu
• createTextImporter • getQuerySetNames • getQ
• createExcelImporter • getMainNodeQuery • get
• setHeaderOption • getSubNodeQuery • get
• setMainNodesetMode • getLinkQuery • get
• setSubNodesetMode • deleteQuerySet • del
• set1modeEdgeListMode • setMainNodeQuery • set
• set1modeMatrixMode • setSubNodeQuery • set
• set1modeLinkedListMode • setLinkQuery • set
• set2modeEdgeListMode • runQuerySet • ru
• set2modeMatrixMode
• set2modeLinkedListMode
• setAttributeInfo
• setTargetWorkfile
• setDiscardNewlyDiscoveredNodes
• runImport
4
2
Report Handling
2.5 Setting a Report
2.1 Main Report________________ 59________________ 88
• getMainReport • getMainReport
• getStringTable • getStringTable • setTitle • setTitle
• getHtmlData • getHtmlData • setColumnChecked • setColumnChec
• setColumnHeaderShow • setColumnHead
2.2 Table Report _______________ 62 _______________ • setAllColumnUnchecked • setAllColumnU
• getTableReport • getTableReport • setColumnName • setColumnNam
• getAttributeNames • getAttributeNames
• getStringTable 2.6 Saving a Report
• getStringTable 92
• addTo1modeNetwork • addTo1modeNetwork
• addTo2modeNetwork • saveToExcel
• addTo2modeNetwork • saveToExcel
• addTo1modeLinkAttribute • saveToExcelAttachRight
• addTo1modeLinkAttribute • saveToExcelAt
• addTo2modeLinkAttribute • saveToExcelAttachBottom
• addTo2modeLinkAttribute • saveToExcelAt
• addToNodeAttribute • saveToCSV
• addToNodeAttribute • saveToCSV
• saveToCSVAttachRight • saveToCSVAtta
2.3 Map Report 69 • saveToCSVAttachBottom • saveToCSVAtta
• getMapReport • getMapReport
• getFocusedMapReport • getFocusedMapReport
• getNodeList • getNodeList
• getIndex • getIndex
• getLabel • getLabel
• getLabelPlace • getLabelPlace
• getSelection • getSelection
• setLabel • setLabel
• setLabelPlace • setLabelPlace
• setSize • setSize
• setColor • setColor
• setShape • setShape
• setSelection • setSelection
• setPictureFilePath • saveToImage
• saveToImage • layout
• layout • redraw
• redraw • nodeAttributeStyling
• nodeAttributeStyling
86
2.4 Chart Report • getChartReport
• getChartReport • saveToImage
• saveToImage
5
3
Matrix Data Handling
3.1 Creating a Matrix 98 3.3 Matrix 109
• identityMatrix • • getElement
identityMatrix
• zeroMatrix • • getColumnVector
zeroMatrix
• randomMatrix • • getRowVector
randomMatrix
• diagonalMatrix • • getDiagonalVector
diagonalMatrix
• copy • copy • getRowSize
• getColumnSize
3.2 NetMiner workfile Get and Add 101 • getMatrixSize
• getMainNodeAttribute • • getMatrixSum
getMainNodeAttribute
• getSubNodeAttribute • • getColumnSum
getSubNodeAttribute
• get1modeNetwork • • getRowSum
get1modeNetwork
• get2modeNetwork • • getLowerSum
get2modeNetwork
• addToMainNodeAttribute • • getUpperSum
addToMainNodeAttribute
• addToSubNodeAttribute • • trace (or getDiagonalSum)
addToSubNodeAttribute
• addTo1modeNetwork • • getCardinality
addTo1modeNetwork
• addTo2modeNetwork • • setElement
addTo2modeNetwork
• addToLinkAttribute • • setZeros
addToLinkAttribute
• dichotomize
• symmetrize
• transpose
• inverse
• elemWiseMult
• elemWiseDiv
• elemWisePow
• isSymmetric
• isDichotomized
• getFullIterator
• getRowIterator
• next
• hasnext
6
4
Dialog Handling
4.1 File Dialog 130
• openFileOpenDialog • openFileOpenDialog
• openFileSaveDialog • openFileSaveDialog
4.2 Directory Dialog 132
• openDirectoryDialog • openDirectoryDialog
4.3 Custom Dialog 133
• createCustomDialog • createCustomDialog
• addComboBoxVariable • addComboBoxVariable
• addDirectoryVariable • addDirectoryVariable
• addFileOpenVariable • addFileOpenVariable
• addFileSaveVariable • addFileSaveVariable
• addIntegerVariable • addIntegerVariable
• addRealVariable • addRealVariable
• addStringVariable • addStringVariable
• open • open
4.4 Message Box 138
• openMessageBox openMessageBox
4.5 HTML Dialog 139
• openHtmlDialog • openHtmlDialog
4.6 Status Dialog 140
• showStatusDialog • showStatusDialog
• closeStatusDialog • closeStatusDialog
7
5
Script Controlling
• pause (page 142)
• stop (page 142)
8
Each function will be explained with the following properties:
Dependency: This is a class that contains functions. It can be in two different
formats.
_NM.Dataset.getMainAttributeNames
mainReport1 = thisSession1.getMainReport(…)
something = mainReport1.getStringTable(…)
thisSession1 = _NM.Session.createSession(…)
theName = thisSession1.getSessionName( )
9
syntax.
Thus, syntax may express either no return value or no input parameter depending on how the
function is being used.
Input Parameter: describes an input parameter with its data type, which is
expressed inside a bracket.
Return Value: describes a return value with its data type, which is expressed inside
a bracket
Example: contains an example script to aid users in using the function. However, an
example script may only work on certain conditions. These restrictions would be
explained in ‘Note.’
Note: contains any additional information about a function or an associated example
including the description of any restrictions for using an example script.
10
How to read this document:
11
1 Data Handling
1.1 Project
openProject
Dependency _NM.Project
Description This function loads a project (i.e. a designated nmf file).
Syntax _NM.Project.openProject (filepath, [ password ] )
Input filepath (String): nmf file path and file name.
Parameter password (String): password for an nmf file.
Return Value None
Example filepath = r"%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\01.Org_Net_Tiny1.nmf";
_NM.Project.openProject(filepath);
Note When specifying a file path, you need to include ‘r’ in front of the path,
which must be in a String type. Adding ‘r’ allows NetMiner to recognize
particular symbols such as ‘\’.
Caveat: the file path provided in the above example is applicable only if
you have installed NetMiner 4 at the default path.
12
newProject
Dependency _NM.Project
Description This function creates a new blank project (after closing the current project)
Syntax _NM.Project.newProject( )
Input None
Parameter
Return Value None
Example _NM.Project.newProject( );
Note You need to save the current project before executing this function since it
would not save the current project when creating a new project.
saveProject
Dependency _NM.Project
Description This function saves the current project. Alternatively, you may choose to
go to ‘File > Save’ in NetMiner 4 menu.
Syntax _NM.Project.saveProject( )
Input None
Parameter
Return Value None
Example _NM.Project.saveProject( );
13
saveAsProject
Dependency _NM.Project
Description This function saves the current project with a different name.
Alternatively, you may choose to go to ‘File > SaveAs’ in NetMiner 4
menu.
Syntax _NM.Project.saveAsProject(filepath, [ NMSaveOption, NMVSaveOption ])
Note When specifying a file path, you need to include ‘r’ in front of the path,
which must be in a String type. Adding ‘r’ allows NetMiner to recognize
particular symbols such as ‘\’.
Caveat: the file path provided in the above example is applicable only if
you have installed NetMiner 4 at the default path.
14
1.2 Workfile
selectWorkfile
Dependency _NM.Workfile
Description This function opens a specified workfile in the current project.
Syntax _NM.Workfile.selectWorkfile( workfileName )
Input workfileName (String) : a workfile name to be opened in the current
Parameter project.
Return Value None
Example _NM.Workfile.selectWorkfile("01.Org_Net_Tiny1");
Note This function executes only when there is a specified workfile in the
current project.
getWorkfileNames
Dependency _NM.Workfile
Description This function returns a list of workfile names. These are the workfiles
located in the current project.
Syntax workfileNameList = _NM.Workfile.getWorkfileNames()
Input None
Parameter
Return Value nameList (String [ ]) : a list of workfile names.
Example workfileNameList = _NM.Workfile.getWorkfileNames( );
Note This function executes only when there is at least one workfile in the
current project.
15
getCurrentWorkfileName
Dependency _NM.Workfile
Description This function returns the name of a currently opened workfile.
Syntax currentWorkfileName = _NM.Workfile. getCurrentWorkfileName( )
Input None
Parameter
Return Value currentWorkfileName (String) : the name of a current workfile.
Example currentWorkfileName = _NM.Workfile. getCurrentWorkfileName ( )
16
1.3 Dataset
getMainAttributeNames
Dependency _NM.Dataset
Description This function returns a list of attributes’ names in a main nodeset.
Syntax mainAttributeNames = _NM.Dataset.getMainAttributeNames( )
Input None
Parameter
Return Value mainAttributeNames(String [ ]) : a list of attribute names in a main
nodeset.
Example mainAttributeNames = _NM.Dataset.getMainAttributeNames();
getSubAttributeNames
Dependency _NM.Dataset
Description This function returns a list of attributes’ names in a sub nodeset.
Syntax subAttributeNames = _NM.Dataset.getSubAttributeNames( nodeSetName )
Input nodeSetName (String) : the name of a sub nodeset.
Parameter
Return Value subAttributeNames(String [ ]) : a list of attribute names in a designated
sub nodeset.
Example subAttributeNames = _NM.Dataset.getSubAttributeNames(“Clubs”);
17
getSubNodeSetNames
Dependency _NM.Dataset
Description This function returns a list of sub nodeset names.
Syntax subNodeNames = _NM.Dataset.getSubNodeSetNames( )
Input None
Parameter
Return Value subNodeNames(String [ ]) : a list of sub nodeset names.
Example subNodeNames = _NM.Dataset.getSubNodeSetNames( );
get1modeNetworkNames
Dependency _NM.Dataset
Description This function returns a list of 1-mode networks’ names.
Syntax networkNames = _NM.Dataset.get1modeNetworkNames( )
Input None
Parameter
Return Value networkNames (String [ ]) : a list of 1-mode networks’ names.
Example oneModeNetworkNames = _NM.Dataset.get1modeNetworkNames();
18
get2modeNetworkNames
Dependency _NM.Dataset
Description This function returns a list of 2-mode networks’ names. These 2-mode
networks would have a designated sub nodeset as their set of target nodes.
Syntax networkNames = _NM.Dataset.get2modeNetworkNames( nodeSetName )
Input nodeSetName (String) : the name of a sub nodeset.
Parameter
Return Value networkNames (String [ ]) : a list of 2-mode networks’ names.
Example twoModeNetworkNames = _NM.Dataset.get2modeNetworkNames("Clubs");
19
getMainAttributeValues
Dependency _NM.Dataset
Description This function returns the values of an attribute from a main nodeset
designated by a user.
Syntax attributeValues = _NM.Dataset.getMainAttributeValues( attName )
Input attName (String) : the name of an attribute from which this function get
Parameter the values.
Return Value attributeValues (Object [ ]) : a list of values from a specified attribute of
the main nodeset.
Example mainAttributeValues = _NM.Dataset.getMainAttributeValues("Gender");
Note The number of values would be equal to the number of nodes and these
values will be returned from the lowest node index to the highest node
index (e.g. node index 1 to node index 22).
20
getSubAttributeValues
Dependency _NM.Dataset
Description This function returns the values of an attribute from a sub nodeset
designated by a user.
Syntax attributeValues =
_NM.Dataset.getSubAttributeValues( nodeSetName , attName )
Input nodeSetName (String) : the name of a sub nodeset.
Parameter attName (String) : the name of an attribute from which this function
get the values.
Return Value attributeValues (Object [ ]) : a list of values from a specified attribute of
the specific sub nodeset.
Example subAttributeValues = _NM.Dataset.getSubAttributeValues("Clubs", “Manager”);
Note The number of values would be equal to the number of nodes and these
values will be returned from the lowest node index to the highest node
index (e.g. node index 1 to node index 22).
Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
21
deleteMainAttribute
Dependency _NM.Dataset
Description This function deletes the attribute of a main nodeset designated by a user.
Syntax _NM.Dataset.deleteMainAttribute( attName )
Input attName (String) : the name of an attribute to be deleted.
Parameter
Return Value None
Example _NM.Dataset.deleteMainAttribute("Gender");
deleteSubAttribute
Dependency _NM.Dataset
Description This function deletes the attribute of a sub nodeset designated by a user.
Syntax _NM.Dataset.deleteSubAttribute( nodeSetName, attName )
Input nodeSetName (String) : the name of a sub nodeset.
Parameter attName (String) : the name of an attribute to be deleted.
Return Value None
Example _NM.Dataset.deleteSubAttribute("Clubs", "Name");
Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
22
deleteNetwork
Dependency _NM.Dataset
Description This function deletes a network designated by a user.
Syntax _NM.Dataset.deleteNetwork( networkName )
Input networkName (String) : the name of a network to be deleted.
Parameter
Return Value None
Example _NM.Dataset.deleteNetwork("personal help");
Note
Caveat: the input parameter of the above example is only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
23
1.4 Import
createTextImporter
Dependency _NM.Import
Description This function creates an importer object for importing a text file.
Syntax thisImporter =
_NM.Import.createTextImporter( filepath , [ separator, textQualifier ] )
Input filepath (String): the path and the name for a text file to be imported
Parameter (i.e. *.txt, *.csv).
separator (String): sets a separator for splitting a cell. The default
value is ‘,’ for a csv file and ‘\t’ for a txt file. For other file extensions,
their separators are blank (‘ ‘).
textQualifier (String) : every text attribute value in between the
qualifier or a character would be read as it is.
Return Value thisImporter (importer) : an importer object that can be used to call import-
related functions.
Example filepath = r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\02.1-mode Network Data
\00.Edge List\work interact_weighted.csv' ;
importer = _NM.Import.createTextImporter(filepath);
Note When specifying a filepath, make sure that the path is in a String type and
‘r’ is added in front of the path, which would allow NetMiner 4 to
recognize particular symbols such as ‘\.’
24
createExcelImporter
Dependency _NM.Import
Description This function creates an importer object for importing an Excel file.
Syntax thisImporter = _NM.Import.createExcelImporter( filepath, [ sheetName ] )
Input filepath (String) : the Excel filepath and the name of a file to be
Parameter imported
sheetName (String) : the sheet name of an Excel file to be imported.
The default value is the name of the first sheet of an Excel file.
Return Value thisImporter (importer) : an importer object that can be used to call import-
related functions.
Example filepath = r'%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\02.1-mode Network Data\00.Edge List\work
interact_weighted.xls' ;
importer = _NM.Import.createExcelImporter(filepath);
Note When specifying a filepath, make sure that the path is in a String type and
‘r’ is added in front of the path, which would allow NetMiner 4 to
recognize particular symbols such as ‘\.’
25
setHeaderOption
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function determines whether the data to be imported has a row
header (and/or a column header) or not.
Syntax thisImporter.setHeaderOption( containsRowHeader ,
containsColumnHeader )
Input containsRowHeader (Boolean) : specifies whether a row header
Parameter exists (True) or not (False)
containsColumnHeader (Boolean) : specifies whether a column
header exists (True) or not (False)
Return Value None
Example importer = _NM.Import.createExcelImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\01.Main Nodeset\Employee.xls');
importer.setHeaderOption(False, True);
Note Caveat: the file path in above example works only if NetMiner 4 is
installed at the default path.
26
setMainNodesetMode
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function imports a main nodeset.
Syntax thisImporter.setMainNodesetMode ( [ idColumnIndex ] )
Input idColumnIndex (int) : the index of a column to use a node ID. The
Parameter default value is the first column (i.e. idColumnIndex = 0)
Return Value None
Example importer = _NM.Import.createExcelImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\01.Main Nodeset\Employee.xls');
importer.setHeaderOption(False, True);
importer.setMainNodesetMode( );
Note Caveat: the file path in above example works only if NetMiner 4 is
installed at the default path.
27
setSubNodesetMode
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function imports a sub nodeset.
Syntax thisImporter.setSubNodesetMode ( targetNodeSet , [ idColumnIndex ] )
Input targetNodeSet (String) : the name of a sub nodeset to be displayed.
Parameter idColumnIndex (int) : the index of a column to use a node ID. The
default value is the first column (i.e. idColumnIndex = 0).
Return Value None
Example importer = _NM.Import.createExcelImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\03.Sub Nodeset\Clubs.xls');
importer.setHeaderOption(False, True);
importer.setSubNodesetMode("Clubs");
Note If there is a sub nodeset with the same name, an existing sub nodeset will
be replaced by a new sub nodeset with the same name.
28
set1modeEdgeListMode
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function imports a 1-mode network as an edge list.
Syntax thisImporter.set1modeEdgeListMode ( networkName, [ sourceIndex,
targetIndex, weightIndex, directed, mergeOption ] )
Input networkName (String) : the name of a network to be imported.
Parameter sourceIndex (int) : the column index of a source. The default value is
0.
targetIndex (int) : the column index of a target. The default value is 1.
weightIndex (int) : the column index of a weight value. The default
value is 2.
directed (Boolean) : specifies whether a network is directed (True) or
not (False). The default value is True.
mergeOption (String) : if a ‘directed’ parameter is set to False, a user
may set the merge type (i.e. ‘SUM’, ‘AVERAGE’, ‘MIN’, ‘MAX’,
‘ALLOW’)
An ‘ALLOW’ type ‘allows’ users to set multiple links.
The default merge type is ‘MAX.’
Each option can be written in either a lower case or an upper case.
Return Value None
Example importer = _NM.Import.createTextImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\02.1-mode Network Data
\00.Edge List\work interact_weighted.csv');
importer.setHeaderOption(False, False);
importer.set1modeEdgeListMode("work Interact");
Note The index starts from 0 hence the column’s first index is 0.
Each merge type means:
SUM : X ′ 𝑖,𝑗 = X𝑖,𝑗 + X𝑗,𝑖
(X𝑖,𝑗 + X𝑗,𝑖 )
AVERAGE : X ′ 𝑖,𝑗 = 2
MIN : X ′ 𝑖,𝑗 = min(𝑋𝑖,𝑗 + 𝑋𝑗,𝑖 )
MAX : X ′ 𝑖,𝑗 = max(𝑋𝑖,𝑗 + 𝑋𝑗,𝑖 )
To import data without a weight, a ‘weightIndex’ input parameter must be
set to -1. If the value for a ‘weightIndex’ input parameter exceeds the
29
number of columns, the function treats the data as data without a weight.
30
set1modeMatrixMode
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function imports a 1-mode network as a matrix.
Syntax thisImporter.set1modeMatrixMode ( networkName, [ matrixType,
includeDiagonal, directed, mergeOption ] )
Input networkName (String) : the name of a network to be imported.
Parameter matrixType (String) : the type of a matrix to be imported (i.e. ‘Full’,
‘UpperHalf’ or ‘LowerHalf’). The default type is ‘Full.’
includeDiagonal (Boolean) : specifies whether a matrix would include
diagonal values (True) or not (False). The default type is ‘Full.’
directed (Boolean) : specifies whether a network is directed (True) or
not (False). The default value is True.
mergeOption (String) : if a ‘directed’ parameter is False, a user may
set the type of merge (i.e. ‘SUM’, ‘AVERAGE’, ‘MIN’, ‘MAX’,
‘ALLOW’)
An ‘ALLOW’ type ‘allows’ users to set multiple links.
The default merge type is ‘MAX.’
Each option can be written in either a lower case or an upper case.
Return Value None
Example importer = _NM.Import.createTextImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\02.1-mode Network Data
\01.Matrix\known personally.csv');
importer.setHeaderOption(True, True);
importer.set1modeMatrixMode("known personally");
Note Each type of a matrix means:
Full: a matrix that has all
of the elements, both
upper and lower, centered
on the diagonal
UpperHalf : a matrix that
only has upper elements
centered on the diagonal.
31
LowerHalf : a matrix that only has lower elements centered on the
diagonal.
set1modeLinkedListMode
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function imports a 1-mode network as a linked list.
Syntax thisImporter.set1modeLinkedListMode ( networkName, [ ranked,
directed, mergeOption ] )
Input networkName (String) : the name of a network to be imported.
Parameter ranked (Boolean) : specifies whether or not the weight values of
neighbor nodes in a linked list is in an incremental order (i.e. 1, 2, … ,
k). The default value is False.
directed (Boolean) : specifies whether a network is directed (True) or
not (False). The default value is True.
mergeOption (String) : if a ‘directed’ parameter is set to False, a user
may set the merge type (i.e. ‘SUM’, ‘AVERAGE’, ‘MIN’, ‘MAX’,
‘ALLOW’)
An ‘ALLOW’ type ‘allows’ users to set multiple links.
The default merge type is ‘MAX.’
Each option can be written in either a lower case or an upper case.
Return Value None
32
Example importer = _NM.Import.createExcelImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\02.1-mode Network Data
\02.Linked List\personal friend.xls');
importer.setHeaderOption(False, False);
importer.set1modeLinkedListMode("personal friend");
Note The index starts from 0 hence the column’s first index is 0.
Each merge type means:
SUM : X ′ 𝑖,𝑗 = X𝑖,𝑗 + X𝑗,𝑖
(X𝑖,𝑗 + X𝑗,𝑖 )
AVERAGE : X ′ 𝑖,𝑗 =
2
set2modeEdgeListMode
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function imports a 2-mode network as an edge list.
Syntax thisImporter.set2modeEdgeListMode ( networkName, targetNodeSet
[ sourceIndex, targetIndex, weightIndex, mergeOption ] )
Input networkName (String) : the name of a network to be imported.
Parameter targetNodeSet (String) : the name of a sub nodeset used as a target.
sourceIndex (int) : the column index of a source. The default value is
0.
targetIndex (int) : the column index of a target. The default value is 1.
weightIndex (int) : the column index of a weight value. The default
value is 2.
mergeOption (String) : if a ‘directed’ parameter is set to False, a user
may set the merge type (i.e. ‘SUM’, ‘AVERAGE’, ‘MIN’, ‘MAX’,
‘ALLOW’)
An ‘ALLOW’ type ‘allows’ users to set multiple links.
The default merge type is ‘MAX.’
33
Each option can be written in either a lower case or an upper case.
Return Value None
Example importer = _NM.Import.createExcelImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\04.2-mode Network Data
\00.Edge List\Purchase.xls');
importer.setHeaderOption(False, False);
importer.set2modeEdgeListMode("Purchase","TargetNodes");
Note The index starts from 0 hence the column’s first index is 0.
Each merge type means:
SUM : X ′ 𝑖,𝑗 = X𝑖,𝑗 + X𝑗,𝑖
(X𝑖,𝑗 + X𝑗,𝑖 )
AVERAGE : X ′ 𝑖,𝑗 = 2
34
set2modeMatrixMode
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function imports a 2-mode network as a matrix.
Syntax thisImporter.set2modeMatrixMode ( networkName, targetNodeSet
[ matrixType, includeDiagonal, mergeOption ] )
Input networkName (String) : the name of a network to be imported.
Parameter targetNodeSet (String) : the name of a sub nodeset used as a target.
matrixType (String) : the type of a matrix to be imported (i.e. ‘Full’,
‘UpperHalf’ or ‘LowerHalf’). The default type is ‘Full.’
includeDiagonal (Boolean) : specifies whether a matrix would include
diagonal values (True) or not (False). The default type is ‘Full.’
mergeOption (String) : if a ‘directed’ parameter is set to False, a user
may set the merge type (i.e. ‘SUM’, ‘AVERAGE’, ‘MIN’, ‘MAX’,
‘ALLOW’)
An ‘ALLOW’ type ‘allows’ users to set multiple links.
The default merge type is ‘MAX.’
Each option can be written in either a lower case or an upper case.
Return Value None
Example importer = _NM.Import.createExcelImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\04.2-mode Network Data
\01.Matrix\Club Affiliation.xls');
importer.setHeaderOption(True, True);
importer.set2modeMatrixMode("Club Affilation", "Clubs");
Note Each type of a matrix means:
Full: a matrix that has all
of the elements, both
upper and lower, centered
on the diagonal
UpperHalf : a matrix that
only has upper elements
centered on the diagonal.
LowerHalf : a matrix that only has lower elements centered on the
35
diagonal.
36
set2modeLinkedListMode
Dependency Importer
Description This function is accessible through an importer object using the dot
notation (e.g. object.function()).
This function imports a 2-mode network as a linked list.
Syntax thisImporter.set2modeLinkedListMode ( networkName, targetNodeSet
[ ranked, mergeOption ] )
Input networkName (String) : the name of a network to be imported.
Parameter targetNodeSet (String) : the name of a sub nodeset used as a target.
ranked (Boolean) : specifies whether the weight values of neighbor
nodes in a linked list is in an incremental order (i.e. 1, 2, … , k) or not.
The default value is False.
mergeOption (String) : If a ‘directed’ parameter is set to False, a user
may set the type of merge (i.e. ‘SUM’, ‘AVERAGE’, ‘MIN’, ‘MAX’,
‘ALLOW’)
An ‘ALLOW’ type ‘allows’ users to set multiple links.
The default merge type is ‘MAX.’
Each option can be written in either a lower case or an upper case.
Return Value None
Example importer = _NM.Import.createExcelImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\04.2-mode Network Data
\02.Linked List\Interested In.xls');
importer.setHeaderOption(False, False);
importer.set2modeLinkedListMode("Interested in", "Items");
Note The index starts from 0 hence the column’s first index is 0.
Each merge type means:
SUM : X ′ 𝑖,𝑗 = X𝑖,𝑗 + X𝑗,𝑖
(X𝑖,𝑗 + X𝑗,𝑖 )
AVERAGE : X ′ 𝑖,𝑗 = 2
MIN : X ′ 𝑖,𝑗 = min(𝑋𝑖,𝑗 + 𝑋𝑗,𝑖 )
MAX : X ′ 𝑖,𝑗 = max(𝑋𝑖,𝑗 + 𝑋𝑗,𝑖 )
setAttributeInfo
37
Dependency Importer
Description This function sets the name and the type of an attribute to be imported as a
column of a nodeset or an edge list.
Syntax thisImporter.setAttributeInfo ( columnIndex, attType, [ attName ] )
Input columnIndex (int) : the column index of an attribute whose name and
Parameter type would be specified by a user.
attType (String) : the type of an attribute. The available types are
‘Number,’ ‘Text’, ‘DateTime’ and ‘Time.’ If you choose to type ‘None’
as an attribute type, the type of an attribute will automatically be
chosen from raw data.
attName (String): the name of an attribute. The default value is its
existing name.
Return Value None
Example importer = _NM.Import.createTextImporter(r'%UserProfile%\NetMiner
\SampleData\Cyram Dataset\01.Org_Net_Tiny1\02.1-mode Network Data
\00.Edge List\personal help_with_attribute.csv');
importer.setHeaderOption(False, True);
importer.set1modeEdgeListMode("personal help_with attribute");
importer.setAttributeInfo(3, 'Text', 'aaa');
Note This function only works on columns other than:
the source (columnIndex = 0),
the target (columnIndex = 1) and
the weight column (columnIndex = 2)
38
setTargetWorkfile
Dependency Importer
Description This function creates a workfile, which would contain the result of
importing data.
Syntax thisImporter.setTargetWorkfile ( workfileName , inheritCurrentWorkfile )
39
setDiscardNewlyDiscoveredNodes
Dependency Importer
Description This function sets which newly discovered nodes are to be discarded in an
import process.
Syntax thisImporter.setDiscardNewlyDiscoveredNodes( )
Input None
Parameter
Return Value None
Example importer = _NM.Import.createTextImporter(r’edge list file which included adding node);
importer.setHeaderOption(False, False);
importer.set1modeEdgeListMode(“work Interact”);
importer.setDiscardNewlyDiscoveredNodes();
Note This function is used when:
data had already been imported and
importing a nodeset, which is different from the existing nodeset.
When considering the above example, after opening ’01.Org_Net_Tiny1’
project, an edge list, which includes the added nodes, is imported.
If the function is not used, newly discovered nodes are added by default.
runImport
Dependency Importer
Description This function runs an importer object.
Syntax thisImporter.runImport( )
Input None
Parameter
Return Value None
Example importer.runImport();
Note After running an importer object, a new workfile will be opened as a result
of import process.
40
1.5 Export
createTextExporter
Dependency _NM.Export
Description This function creates an exporter object for exporting a text file.
Syntax thisExporter = _NM.Export.createTextExporter ( filepath, [ separator,
textQualifier, applyQualifierToDateTime ] )
Input filepath (String) : the path and the name of a text file to be imported
Parameter (i.e. *.txt, *.csv).
separator (String) : sets a separator for splitting a cell. The default
value is ‘,’ for a csv file and ‘\t’ for a txt file. For other files, their
separators are blank (‘ ‘).
textQualifier (String) : every text attribute value in between the
qualifier or a character would be read as it is.
applyQualifierToDateTime (Boolean) : determines whether to apply a
text qualifier to DateTime and a time attribute as well. The default value
is False.
Return Value thisExporter (exporter) : an exporter object that contains the functions to
be used in export process.
Example filepath = r' %UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\exportData.csv';
exporter = _NM.Export.createTextExporter(filepath);
Note Caveat: the file path in above example works only if NetMiner 4 is
installed at the default path.
41
createExcelExporter
Dependency _NM.Export
Description This function creates an exporter object for exporting an Excel file.
Syntax thisExporter = _NM.Export.createExcelExporter ( filepath, [ sheetName ] )
Input filepath (String) : the path and the name of an Excel file to be imported
Parameter (i.e. *.txt, *.csv).
sheetName (String) : the sheet name of an Excel file to be exported.
The default value is the name of an Excel base sheet.
Return Value thisExporter (exporter) : an exporter object that contains the functions to
be used in an export process.
Example filepath = r'%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\exportData.xls';
exporter = _NM.Export.createExcelExporter(filepath);
Note Caveat: the file path in above example works only if NetMiner 4 is
installed at the default path.
42
exportMainNodeSet
Dependency Exporter
Description This function is accessible through an exporter object using the dot
notation (e.g. object.function()).
This function exports a main nodeset.
Syntax thisExporter.exportMainNodeSet ( [ includeColumnHeader , includeAttribute ] )
43
exportSubNodeSet
Dependency Exporter
Description This function is accessible through an exporter object using the dot
notation (e.g. object.function()).
This function exports a sub nodeset.
Syntax thisExporter.exportSubNodeSet
( nodeSetName, [ includeColumnHeader , includeAttribute ] )
Input nodeSetName (String) : the name of a sub nodeset to be exported.
Parameter includeColumnHeader (Boolean) : specifies whether a column header
exists (True) or not (False). The default value is True.
includeAttribute (Boolean) : specifies whether to export an attribute(s)
or not. The default value is True.
Return Value None
Example exporter =
_NM.Export.createTextExporter(r'%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\exportData.csv');
exporter.exportSubNodeSet("Clubs", False, True);
Note Caveat: the file path in above example works only if NetMiner 4 is
installed at the default path.
44
exportNetworkToMatrix
Dependency Exporter
Description This function is accessible through an exporter object using the dot
notation (e.g. object.function()).
This function exports a specified network as a matrix.
Syntax thisExporter.exportNetworkToMatrix ( networkName,
[ includeRowHeader, includeColumnHeader, mergeOption ] )
Input networkName (String) : the name of a network to be exported.
Parameter includeRowHeader (Boolean) : specifies whether a row header exists
(True) or not (False). The default value is True.
includeColumnHeader (Boolean) : specifies whether a column header
exists (True) or not (False). The default value is True.
mergeOption (String) : If a ‘directed’ parameter is set to False, a user
may set the merge type (i.e. ‘SUM’, ‘AVERAGE’, ‘MIN’, ‘MAX’,
‘ALLOW’)
An ‘ALLOW’ type ‘allows’ users to set multiple links.
The default merge type is ‘MAX.’
Each option can be written in either a lower case or an upper case.
Return Value None
Example exporter =
_NM.Export.createTextExporter(r‘%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\exportData.csv'); exporter.exportNetworkToMatrix("work
interact");
Note Each merge type means:
SUM : X ′ 𝑖,𝑗 = X𝑖,𝑗 + X𝑗,𝑖
(X𝑖,𝑗 + X𝑗,𝑖 )
AVERAGE : X ′ 𝑖,𝑗 = 2
exportNetworkToEdgeList
45
Dependency Exporter
Description This function is accessible through an exporter object using the dot
notation (e.g. object.function()).
This function exports a specified network as an edge list.
Syntax thisExporter.exportNetworkToEdgeList ( networkName,
[ includeColumnHeader, includeWeight, includeAttribute ] )
Input networkName (String) : the name of a network to be exported.
Parameter includeColumnHeader (Boolean) : specifies whether a column header
exists (True) or not (False). The default value is True.
includeWeight (Boolean) : specifies whether to export a weight value(s)
or not. The default value is True.
includeAttribute (Boolean) : specifies whether to export an attribute(s)
or not. The default value is True.
Return Value None
Example exporter =
_NM.Export.createTextExporter(r'%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\exportData.csv');
exporter.exportNetworkToEdgeList("work interact");
Note Caveat: the file path in above example works only if NetMiner 4 is
installed at the default path.
46
1.6 Session
createSession
Dependency _NM.Session
Description This function creates a new session with a specified name. Alternatively, a
user can select an entered module as a session.
Syntax thisSession = _NM.Session.createSession( sessionType )
Input sessionType (String) : the type of a session to be created
Parameter
Return Value thisSession (session) : a session object with a specified name
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
session2 = _NM.Session.createSession("Analyze>Centrality>Betweenness>Node");
Note As shown above, when creating a module session, as an input parameter, a
user should generally provide the path of a specific menu (e.g.
Analyze>Neighbor>Degree).
openSession
Dependency _NM.Session
Description This function opens an existing session.
Syntax thisSession = _NM.Session.openSession( sessionName )
Input sessionName (String) : the name of a session to be opened
Parameter
Return Value thisSession (session) : a session object with a specified name
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
session1 = _NM.Session.openSession("Degree");
47
closeSession
Dependency _NM.Session
Description This function closes an existing session. Alternatively, a user can click the
close button located on a session window ( ).
Syntax thisSession = _NM.Session.closeSession( sessionName )
Input sessionName (String) : the name of a session to be closed.
Parameter
Return Value None
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
session1 = _NM.Session.openSession("Degree");
_NM.Session.closeSession("Degree");
Note An error will occur if the session with a specified name does not exist.
close
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function closes a specified session, which works like closing a
session window.
Syntax thisSession.close ( )
Input None
Parameter
Return Value None
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
session1.close();
48
deleteSession
Dependency _NM.Session
Description This function deletes an existing session. Alternatively, a user can delete a
session in the project tree.
Syntax thisSession = _NM.Session.deleteSession( sessionName )
Input sessionName (String) : the name of a session to be deleted.
Parameter
Return Value None
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
_NM.Session.deleteSession("Degree")
Note An error will occur if the session with a specified name does not exist.
delete
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function deletes a specified session, which works like deleting a
session in a project tree.
Syntax thisSession.delete ( )
Input None
Parameter
Return Value None
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
session1.delete();
49
getSessionName
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function returns the name of a specified session.
Syntax sessionName = thisSession.getSessionName ( )
Input None
Parameter
Return Value sessionName (String) : the name of a session
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
sessionName = session1.getSessionName();
print sessionName;
setSessionName
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function changes the name of a currently selected session object.
Syntax thisSession.setSessionName ( sessionName )
Input sessionName (String) : the new name for a currently selected session
Parameter object.
Return Value None
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
session1.setSessionName(“newSessionName”);
50
getFocusedSession
Dependency _NM.Session
Description This function returns a session object currently displayed on the screen.
Syntax thisSession = getFocusedSession ( )
Input None
Parameter
Return Value thisSession (Session) : a session object displayed on the screen.
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
session1 = _NM.Session.getFocusedSession();
run
Dependency Session
Description This function is accessible through a Session object using the dot
notation (e.g. object.function()).
This function runs a currently selected session object. Alternatively, a
user can click a ‘Run process’ button in NetMiner.
Syntax thisSession.run ( )
Input None
Parameter
Return Value None
Example session1 = _NM.Session.createSession("Analyze>Neighbor>Degree");
session1.run();
51
saveOutputTables
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function saves the result of executing a session, as a new workfile.
Syntax thisSession.saveOutputTables ( newWorkfileName,
[ addToChildWorkfile , switchToNewWorkfile ] )
Input newWorkfileName (String) : the name of a workfile to be created.
Parameter addToChildWorkfile (Boolean) : specifies whether or not to add a
newly created workfile under the current workfile as a child workfile.
The default value is True.
If False, a new workfile will not be added as a child of a current
workfile.
switchToNewWorkfile (Boolean) : specifies whether to open up a
newly created workfile or not. The default value is True.
If False, a new workfile will not be displayed on the screen.
Return Value None
Example session1 = _NM.Session.createSession("Analyze>Position>Blockmodel
(Conventional)");
session1.setInputAdjacencyName("work interact");
session1.setInputVectorName("Education");
session1.setPostDichotomize(True);
session1.run();
report1 = session1.getMainReport("[R] Main");
report2 = session1.getTableReport("[T] Block Image Matrix");
report3 = session1.getTableReport("[T] Block Density Matrix");
report4 = session1.getTableReport("[T] Block Sum Matrix");
report5 = session1.getTableReport("[T] Block-Node Affiliation Matrix");
report6 = session1.getTableReport("[T] # Nodes");
report7 = session1.getTableReport("[T] Block Role Typology");
report8 = session1.getMapReport("[M] Clustered");
session1.saveOutputTables("Block Matrix");
Note While this function would only work on the session that can save an
output table, it can only be executed after successfully running a session.
Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
1.7 Query
createQuerySet
52
Dependency _NM.Query
Description This function creates a new query set with a specified name. Alternatively,
a user may create a query set in the process log of NetMiner.
Syntax thisQuerySet =_NM.Query.createQuerySet ( querySetName )
Input querySetName (String) : the name of a query set to be created.
Parameter
Return Value thisQuerySet (QuerySet) : a new query set with a specified name.
Example query = _NM.Query.createQuerySet("Gender");
Note If there is a query set with the same name, an existing query set will be
replaced by a new query set with the same name.
getQuerySet
Dependency _NM.Query
Description This function returns an existing query set.
Syntax thisQuerySet =_NM.Query.getQuerySet ( querySetName )
Input querySetName (String) : the name of a query set.
Parameter
Return Value thisQuerySet (QuerySet) : a query set with a specified name
Example query = _NM.Query.getQuerySet("Gender");
Note If there is no query set with a specified name, an error will occur.
getQuerySetNames
Dependency _NM.Query
Description This function returns a list of query set names in the current workfile.
Syntax querySetNameList =_NM.Query.getQuerySetNames( )
Input None
Parameter
53
Return Value querySetNameList (String [ ]) : a list of query set names
Example _NM.Query.createQuerySet("Gender");
_NM.Query.createQuerySet("Rank");
_NM.Query.createQuerySet("Grade");
querySetNameList = _NM.Query.getQuerySetNames();
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
getMainNodeQuery
Dependency QuerySet
Description This function is accessible through a queryset object using the dot
notation (e.g. object.function()).
This function returns a query statement, which will be used to query a
main nodeset.
Syntax querycode = thisQuerySet.getMainNodeQuery ( )
Input None
Parameter
Return Value querycode (String) : a query statement used to query a main nodeset.
Example query = _NM.Query.createQuerySet("Gender");
query.setMainNodeQuery(' "Gender" == "Male" ');
queryCode = query.getMainNodeQuery();
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
54
getSubNodeQuery
Dependency QuerySet
Description This function is accessible through a queryset object using the dot
notation (e.g. object.function()).
This function returns a query statement, which will be used to query a
designated sub nodeset.
Syntax querycode = thisQuerySet.getSubNodeQuery ( nodeSetName )
Input nodeSetName (String) : the name of a sub nodeset for which a user wants
Parameter to query.
Return Value querycode (String) : a query statement used to query a designated sub
nodeset.
Example query = _NM.Query.createQuerySet("itemCategory");
query.setSubNodeQuery("Interest Items", ' "Category" == "alone" ');
queryCode = query.getSubNodeQuery("Interest Items");
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
55
getLinkQuery
Dependency QuerySet
Description This function is accessible through a queryset object using the dot
notation (e.g. object.function()).
This function returns a query statement, which will be used to query a
designated network.
Syntax querycode = thisQuerySet.getLinkQuery ( networkName )
Input networkName (String) : the name of a network for which a user wants to
Parameter query.
Return Value querycode (String) : a query statement used to query a network.
Example query = _NM.Query.createQuerySet("Links");
query.setLinkQuery("personal friend", ' @WEIGHT > 2 ');
queryCode = query.getLinkQuery("personal friend");
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
deleteQuerySet
Dependency _NM.Query
Description This function deletes a query set selected by a user.
Syntax querySetNameList =_NM.Query.deleteQuerySet( querySetName )
Input querySetName (String) : the name of a query set to be deleted.
Parameter
Return Value None
Example _NM.Query.createQuerySet("Gender");
_NM.Query.createQuerySet("Rank");
_NM.Query.createQuerySet("Grade");
_NM.Query.deleteQuerySet("Grade");
Note An error will occur if the query set with a specified name does not exist.
Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
setMainNodeQuery
Dependency QuerySet
Description This function is accessible through a queryset object using the dot
56
notation (e.g. object.function()).
This function sets a query statement used to query a main nodeset.
Syntax thisQuerySet.setMainNodeQuery ( [ query ] )
Input query (String) : a query statement, which must be enclosed with single
Parameter quotes (‘ ’).
As to String variables, they must be enclosed with double quotes
(“ ”).
As to numbers having either int or float type, double quotes are not
used.
As to the node label, @ should always be appended before writing
the actual label (e.g. ‘@LABEL’) and it must not be enclosed with
double quotes.
If a user does not provide a query statement, this function would
delete a query statement in regard to the main nodeset.
Return Value None
Example query = _NM.Query.createQuerySet("Gender");
query.setMainNodeQuery(' "Gender" == "Male" ');
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
57
setSubNodeQuery
Dependency QuerySet
Description This function is accessible through a queryset object using the dot
notation (e.g. object.function()).
This function sets a query statement used to query a sub nodeset.
Syntax thisQuerySet.setSubNodeQuery ( nodeSetName, [ query ] )
Input nodeSetName (String) : the name of a sub nodeset.
Parameter query (String) : a query statement, which must be enclosed with single
quotes (‘ ’).
As to String variables, they must be enclosed with double quotes
(“ ”).
As to numbers having either int or float type, double quotes are not
used.
As to the node label, @ should always be appended before writing
the actual label (e.g. ‘@LABEL’) and it must not be enclosed with
double quotes.
If a user does not provide a query statement, this function would
delete a query statement in regard to the sub nodeset.
Return Value None
Example query = _NM.Query.createQuerySet("itemCategory");
query.setSubNodeQuery("Interest Items", ' "Category" == "alone" ');
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
58
setLinkQuery
Dependency QuerySet
Description This function is accessible through a queryset object using the dot
notation (e.g. object.function()).
This function sets a query statement used to query a network selected
by a user.
Syntax thisQuerySet.setLinkQuery ( networkName, [ query ] )
Input networkName (String) : the name of a network.
Parameter query (String) : a query statement, which must be enclosed with single
quotes (‘ ’).
As to String variables, they must be enclosed by double quotes (“ ”).
As to numbers having either int or float type, double quotes are not
used.
As to source, target or weight values, @ must always be appended
before writing the name of these attributes without double quotes
(e.g. ‘@SOURCE’).
If a user does not provide a query statement, this function would
delete a query statement in regard to the network.
Return Value None
Example query = _NM.Query.createQuerySet("Links");
query.setLinkQuery("personal friend", ' @WEIGHT > 2 ');
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
59
runQuerySet
Dependency QuerySet
Description This function is accessible through a queryset object using the dot
notation (e.g. object.function()).
This function creates a workfile that contains the result of a query set
by a user.
Syntax thisQuerySet.runQuerySet ( newWorkfileName, [ switchToNewWorkfile ] )
60
2 Report Handling
1.1. Main Report
getMainReport
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function returns the main report of a designated session.
Syntax thisMainReport = thisSession. getMainReport ( [ reportName ] )
Input reportName (String) : the tab name of a main report. If the input
Parameter parameter is omitted, by default, this function will return the first main
report tab of the session.
Return Value thisMainReport (MainReport) : a main report object.
getStringTable
Dependency MainReport
Description This function is accessible through a mainreport object using the dot
61
notation (e.g. object.function()).
This function returns the main report of a designated session as a string
table.
Syntax thisMainString = thisMainReport.getStringTable ( dataName )
Input dataName (String) : the name of a table or a value in an output summary
Parameter of the main report (the name is underlined and is in an upper case and
written in gray color)
getHtmlData
Dependency MainReport
Description This function is accessible through a mainreport object using the dot
notation (e.g. object.function()).
62
This function returns a specified table from the main report in an
HTML format.
Syntax htmlData = thisMainReport.getHtmlData( dataName )
Input dataName (String) : the name of a table or a value in an output summary
Parameter of the main report (the name is underlined and is in an upper case and
written in gray color)
63
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function returns a tablereport object of the table report specified
by a user.
Syntax thisTableReport = thisSession.getTableReport( reportName )
Input reportName (String) : the name of a table report tab in the session. If this
Parameter input parameter is not provided by a user, it returns a first table report.
getAttributeNames
Dependency TableReport
Description This function is accessible through a tablereport object using the dot
notation (e.g. object.function()).
This function returns the name of a table report’s attribute(s).
Syntax nameList = thisTableReport.getAttributeNames ( )
Input None
Parameter
64
Return Value nameList (String [ ]) : a list of attributes’ names belonging to a table report
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
nameList = report.getAttributeNames();
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
getStringTable
Dependency TableReport
Description This function is accessible through a tablereport object using the dot
notation (e.g. object.function()).
This function returns an existing table report as a stringtable object.
Syntax thisTableString = thisTableReport. getStringTable ( )
Input None
Parameter
Return Value thisTableString (StringTable) : a String table of the existing table report
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
65
addTo1modeNetwork
Dependency TableReport
Description This function is accessible through a tablereport object using the dot
notation (e.g. object.function()).
This function adds the designated table data as a 1-mode network
dataset.
Syntax thisTableReport. addTo1modeNetwork ( networkName )
Input networkName (String): the name of a 1-mode network dataset to be
Parameter added.
66
addTo2modeNetwork
Dependency TableReport
Description This function is accessible through a tablereport object using the dot
notation (e.g. object.function()).
This function adds the designated table data as a 2-mode network
dataset.
Syntax thisTableReport. addTo2modeNetwork ( networkName )
Input networkName (String): the name of a 2-mode network dataset to be
Parameter added.
Caveat #2: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
67
addTo1modeLinkAttribute
Dependency TableReport
Description This function is accessible through a tablereport object using the dot
notation (e.g. object.function()).
This function adds the designated table data as a link attribute of the 1-
mode network dataset.
Syntax thisTableReport.addTo1modeLinkAttribute ( networkName , attName )
Input networkName (String): the name of a 1-mode network dataset to
Parameter which a link attribute will be added.
attName (String) : the name of a link attribute to be added to a
designated 1-mode network dataset.
Return Value None
Example # Link attribute result (the result of a node pair. This is a shortest path analysis for a 1-
mode network data result)
session1 = _NM.Session.createSession("Analyze>Connection>Shortest Path");
session1.setReportUnselectedItems([2]);
session1.setInputAdjacencyName("work interact");
session1.run();
report = session1.getTableReport("[T] Distance Matrix");
report.addTo1modeLinkAttribute("work interact", "shortestPath");
Note Caveat #1: this function only works on reports that enabled ‘add to 1-
mode link attribute’ functionality.
Caveat #2: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
68
addTo2modeLinkAttribute
Dependency TableReport
Description This function is accessible through a tablereport object using the dot
notation (e.g. object.function()).
This function adds the designated table data as a link attribute of the 2-
mode network dataset.
Syntax thisTableReport.addTo2modeLinkAttribute ( networkName , attName )
Input networkName (String): the name of a 2-mode network dataset to
Parameter which a link attribute will be added.
attName (String) : the name of a link attribute to be added to a
designated 2-mode network dataset.
Return Value None
Example session1 = _NM.Session.createSession("Analyze>Two Mode>Max. Matching");
session1.setInputAffiliationName("Club Affiliation");
session1.setInputAffiliationNodesetName("Clubs");
session1.run();
report = session1.getTableReport("[T] Max. Matching Matrix");
report.addTo2modeLinkAttribute("Club Affiliation", "maxMatching");
Note Caveat #1: this function only works on reports that enabled ‘add to 2-
mode link attribute’ functionality.
Caveat #2: the input parameters of the above example is only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
69
addToNodeAttribute
Dependency TableReport
Description This function is accessible through a tablereport object using the dot
notation (e.g. object.function()).
This function appends the selected table report data (i.e. an attribute) to
a main nodeset as an attribute.
Syntax thisTableReport.addToNodeAttribute ( attName, [ newName ] )
Input attName (String) : the name of an attribute which would be copied to
Parameter a main nodeset as its attribute.
newName (String) : the name of a newly added attribute in a main
nodeset as an output of this function.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
report.addToNodeAttribute("In-Degree Centrality","In");
Note If a user does not provide a new name for the attribute added to a main
nodeset, the original name would be supplied by default.
70
2.3 Map Report
getMapReport
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function returns a mapreport object designated by a user.
Syntax thisMapReport = thisSession.getMapReport ( reportName )
Input reportName (String) : the tab name of a map report. If the input
Parameter parameter is omitted, by default, this function will return the first map
report tab of the session.
Return Value thisMapReport (mapreport) : a mapreport object with a specified name.
Example session1 = _NM.Session.openSession("Degree");
mapReport = session1.getMapReport("[M] Spring");
Note Caveat: the example should execute after performing a degree analysis of
a session with the name ‘Degree.’
71
getFocusedMapReport
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function returns the mapreport object that a user currently displays
on the screen.
Syntax thisMapReport = thisSession.getFocusedMapReport( )
Input None
Parameter
Return Value thisMapReport (mapreport) : a map report object currently displayed on
the screen.
Example session1 = _NM.Session.openSession("Degree");
mapReport = session1.getFocusedMapReport();
Note If the map report is not currently displayed on the screen, this function
would return an object with the type ‘None.’
72
getNodeList
Dependency mapReport
Description This function is accessible through a mapreport object using the dot
notation (e.g. object.function()).
This function returns a list of graphnode objects. A graphnode object
can be used to style nodes and select features.
Syntax thisGraphNodes = thisMapReport.getNodeList( )
Input None
Parameter
Return Value thisGraphNodes (GraphNode [ ]) : a list of graphnode objects, which is
contained in a mapreport object, would be returned.
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
# changes the color of each node to blue
for node in nodeList:
node.setColor(0,0,255);
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
73
getIndex
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function returns the index of a node.
Syntax index = thisGraphNode.getIndex( )
Input None
Parameter
Return Value index (int) : the index of a node in the graphnode object (stored as an
element of an array)
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
print node.getIndex();
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
74
getLabel
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function returns the label of a node from the graphnode object.
Syntax label = thisGraphNode.getLabel( )
Input None
Parameter
Return Value label (String) : the label of a node in the graphnode object
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
label = node.getLabel();
print label;
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
75
getLabelPlace
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function returns the position of a node label from the map report.
Syntax labelPlace = thisGraphNode.getLabelPlace( )
Input None
Parameter
Return Value labelPlace (String) : the position of a graphnode label displayed on the
map report.
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
nodePosition = node.getLabelPlace();
nodeIndex = node.getIndex();
print nodeIndex,':',nodePosition;
Note As to the position of a node, possible values are: ‘North’, ‘Northeast’,
‘Northwest’, ‘East’, ‘West’, ‘South’, ‘Southwest’, ‘Southeast’ or ‘Hidden.’
76
getSelection
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function specifies whether the node of a graph is selected in the
current map report (True) or not (False).
Syntax selection = thisGraphNode.getSelection( )
Input None
Parameter
Return Value selection (Boolean) : if the node is selected on the map, this return value is
True. If not, it is False.
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
nodeIndex = node.getIndex();
if nodeIndex <= 5:
node.setSelection(True);
print node.getSelection();
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
77
setLabel
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function changes the label of a node displayed on the map report.
78
setLabelPlace
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function changes the position of a node label on the map report.
Syntax thisGraphNode.setLabelPlace( labelPlace )
Input labelPlace (String) : a new position of the designated node label. The
Parameter available options are: ‘North’, ‘Northeast’, ‘Northwest’, ‘East’, ‘West’,
‘South’, ‘Southwest’, ‘Southeast’ or ‘Hidden.’
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
node.setLabelPlace("North");
Note The setting will be applied instantly after using a redraw function.
However, the changes will still be applied without applying a redraw
function if a user clicks on the map report (e.g. the map itself).
79
setSize
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function changes the size of a node displayed on the map report.
Syntax thisGraphNode. setSize ( width , height )
Input width (int) : width of a node
Parameter height (int) : height of a node
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
node.setSize(50, 50);
Note The setting will be applied instantly after using a redraw function.
However, the changes will still be applied without applying a redraw
function if a user clicks on the map report (e.g. the map itself).
80
setColor
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function changes the color of a node displayed on the map report
using RGB values.
Syntax thisGraphNode.setColor ( red , green, blue )
Input red (int) : the degree of redness (ranging from 0 to 255)
Parameter green (int) : the degree of greenness (ranging from 0 to 255)
blue (int) : the degree of blueness (ranging from 0 to 255)
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
node.setColor(0,0,255) # (0,0,255) : BLUE
Note The setting will be applied instantly after using a redraw function.
However, the changes will still be applied without applying a redraw
function if a user clicks on the map report (e.g. the map itself).
81
setShape
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function changes the shape of a node displayed on the map report.
Syntax thisGraphNode.setShape ( shape )
Input shape (String) : a desired shape for the node. The available options are:
Parameter
82
setSelection
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function sets the status (i.e. either selected or not selected) of a
node displayed on a map report.
Syntax thisGraphNode.setSelection ( selection )
Input selection (Boolean) : if the value is set to True, the node would be
Parameter highlighted in yellow, which indicates that the node is selected. If the
value is set to False, the node would not be selected.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
nodeIndex = node.getIndex();
if nodeIndex <= 5:
node.setSelection(True);
Note The setting will be applied instantly after using a redraw function.
However, the changes will still be applied without applying a redraw
function if a user clicks on the map report (e.g. the map itself).
83
setPictureFilePath
Dependency graphNode
Description This function is accessible through a graphnode object using the dot
notation (e.g. object.function()).
This function fills a node with the picture designated by a user.
Syntax thisGraphNode.setPictureFilePath ( filePath )
Input filePath (String) : the path of a picture file to be used for styling a node.
Parameter
Return Value None
Example session1 = _NM.Session.createSession("Visualize>Spring>2D");
session1.run();
report1 = session1.getMapReport("[M] Spring 2D");
report1.setLayerAdjcencyList(["Trust"]);
report1.setLayoutAlgorithmGroupOptionName("Spring");
report1.setLayoutAlgorithmName("Kamada & Kawai");
options = {};
options["Max # Iterations"] = 500;
options["EPS"] = 0.0001;
options["Natural Length Coefficient"] = 1.0;
options["Between Component Factor"] = 2;
report1.setLayoutAlgorithmOptionValues(options);
report1.layout();
nodes = report1.getNodeList();
paths = _NM.Dataset.getMainAttributeValues("Path");
genders = _NM.Dataset.getMainAttributeValues("Gender");
for node, path, gender in zip(nodes, paths, genders):
node.setPictureFilePath(path);
if gender == "female":
node.setSize(50,50);
else:
node.setSize(20,20);
report1.redraw();
Note The setting will be applied instantly after using a redraw function.
However, the changes will still be applied without applying a redraw
function if a user clicks on the map report (e.g. the map itself).
saveToImage
Dependency MapReport
84
Description This function is accessible through a mapreport object using the dot
notation (e.g. object.function()).
This function saves a map report as an image file.
Syntax thisMapReport.saveToImage ( filepath, [ width , height ] )
Input filepath (String) : the location and the name of an image file to be
Parameter saved.
only bmp, jpg and png extensions are allowed.
width (int) : width of an image. The default value is 1024.
height (int) : height of an image. The default value is 768.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getMapReport("[M] Spring");
report.saveToImage(r"%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\sampleMap.jpg",500, 500);
Note As to 3D maps, the height and the width settings are disabled. Regardless
of the height and the width parameter, image size of 3D maps would be
exactly same as the size of maps displayed on the map report.
Caveat #1: the file path provided in the above example is applicable only
if you have installed NetMiner 4 at the default path.
85
layout
Dependency MapReport
Description This function is accessible through a mapreport object using the dot
notation (e.g. object.function()).
This function applies the changes in layout. Alternatively, you can
execute ‘performing run layout’ directly in NetMiner.
Syntax thisMapReport.layout ( )
Input None
Parameter
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
# changes the layout of a current map
report1.setLayoutAlgorithmName("Eades"); # Apply Eades layout Algorithm
options = {};
options["Max # Iterations"] = 500;
options["EPS"] = 0.0001;
options["Repulsiveness Coefficient"] = 1.0;
options["Attenuation Factor"] = 1.0;
options["Natural Length Coefficient"] = 1.0;
report1.setLayoutAlgorithmOptionValues(options);
# save map image before running a layout function
report1.saveToImage(r"%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\sampleMap.jpg",500, 500);
# applies the changes in layout
report1.layout();
# save map image after running layout function
report1.saveToImage(r"%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\sampleMap2.jpg",500, 500);
Note Caveat #1: the file path provided in the above example is applicable only
if you have installed NetMiner 4 at the default path.
86
redraw
Dependency MapReport
Description This function is accessible through a mapreport object using the dot
notation (e.g. object.function()).
This function redraws the current map in order to apply the changes in
style to the current map.
Syntax thisMapReport.redraw ( )
Input None
Parameter
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
nodeList = report1.getNodeList();
for node in nodeList:
node.setColor(0,0,255);
report1.redraw();
Note Caveat #1: When you have changed the style of each node directly, the
changes would be reflected after you have redrawn the map using this
function.
87
nodeAttributeStyling
Dependency MapReport
Description This function is accessible through a mapreport object using the dot
notation (e.g. object.function()).
This function applies the styles to the nodes according to the values of
a node attribute designated by a user.
Syntax thisMapReport.nodeAttributeStyling ( attName, [stylingType] )
Input attName (String) : the name of a node attribute used to style nodes
Parameter according to its values.
stylingType (String) : the name of a styling type. The available
options are : ‘quick’, ‘shape’, ‘color’ and ‘size’. The default value is
‘quick’.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report1 = session1.getMapReport("[M] Spring");
report1.nodeAttributeStyling("Gender", "color");
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
88
2.4 Chart Report
getChartReport
Dependency Session
Description This function is accessible through a session object using the dot
notation (e.g. object.function()).
This function returns a chartreport object specified by a user.
Syntax chartReport = thisSession.getChartReport ( [ reportName ] )
Input reportName (String) : the name of a chart report. If a user does not
Parameter provide this input parameter, the first chart report is returned.
Return Value chartReport (ChartReport) : the chartreport object of a specified name.
Example session1 = _NM.Session.createSession("Statistics>Frequency>Vector");
session1.setInputVectorName("Education");
session1.run();
chartReport = session1.getChartReport("[C] Pie Plot");
Note Caveat: the example should execute after running an analysis session that
includes a chart report.
89
saveToImage
Dependency ChartReport
Description This function is accessible through a chartreport object using the dot
notation (e.g. object.function()).
This function saves the chart report as an image file.
Syntax chartReport = thisSession.saveToImage ( filepath, [ width , height ] )
Input filepath (String) : the location and the name of an image file to be
Parameter saved.
only bmp, jpg and png extensions are allowed.
width (int) : width of an image. The default value is 1024.
height (int) : height of an image. The default value is 768.
Return Value chartReport (ChartReport) : the chartreport object of a specified name.
Example session1 = _NM.Session.createSession("Statistics>Frequency>Vector");
session1.setInputVectorName("Education");
session1.run();
chartReport = session1.getChartReport("[C] Pie Plot");
chartReport.saveToImage(r"%UserProfile%\NetMiner\SampleData\Cyram
Dataset\01.Org_Net_Tiny1\sampleMap.jpg",500, 500);
Note Caveat #1: the file path provided in the above example is applicable only
if you have installed NetMiner 4 at the default path.
Caveat #2: the example should execute after running an analysis session
that includes a chart report.
90
2.5 Setting a Report
setTitle
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function sets the title of a string table.
Syntax thisStringTable.setTitle ( [ title ] )
Input title (String) : the title of a string table. If omitted, there would be no title.
Parameter
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
stringReport.setTitle("Title");
Note If you do not want the title, write ‘None’ as a title (input parameter).
91
setColumnChecked
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function either displays or does not display a column designated
by a user.
Syntax thisStringTable.setColumnChecked ( colName, [ checked ] )
Input colName (String) : the name of a column, which would be either
Parameter displayed or not displayed.
checked (Boolean) : the specified column will be displayed if the
value is set to True. If the value is False, the column will not be
displayed. The default value is True.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
stringReport.setColumnChecked("In-Degree Centrality", False);
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
92
setColumnHeaderShow
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function either displays or does not display a column header(s).
Syntax thisStringTable.setColumnHeaderShow( columnHeaderShow )
Input columnHeaderShow (Boolean) : If the value is True, a column header(s)
Parameter appears. If False, a column header does not appear.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
stringReport.setColumnHeaderShow(False);
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
setAllColumnUnchecked
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function hides every column header.
Syntax thisStringTable.setAllColumnUnchecked( )
Input None
Parameter
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
stringReport.setAllColumnUnchecked();
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
setColumnName
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
93
notation (e.g. object.function()).
This function changes the name of a specified column to a new name
provided by a user.
Syntax thisStringTable.setColumnName ( originalName , newName )
Input originalName (String) : a column name that a user wants to change
Parameter newName (String) : a new column name of the column that has
originalName as its name.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
stringReport.setColumnName("In-Degree Centrality", "New Name");
Note Caveat: the example should execute after performing a degree centrality
analysis of a session with the name ‘Degree Centrality.’
94
2.6 Saving a Report
saveToExcel
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function saves a string table as an Excel file.
Syntax thisStringTable.saveToExcel( filepath , sheetName )
Input filepath (String) : the file path and the name of an Excel file to be
Parameter created.
sheetName (String) : the sheet name of an Excel file to be created.
95
saveToExcelAttachRight
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function saves a string table as an Excel file. If there is an Excel
file with the same name, a string table will be appended to the right
side of an existing content with a margin specified by a user.
Syntax thisStringTable.saveToExcelAttachRight ( filepath , sheetName, [ margin ] )
Input filepath (String) : the file path and the name of an Excel file to be
Parameter created.
sheetName (String) : the sheet name of an Excel file to be created.
margin (int) : the space between an existing content and a new string
table. The default value is 2.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
filePath = r"%UserProfile%\NetMiner\SampleData\Cyram Dataset
\01.Org_Net_Tiny1\excelSample.xls";
stringReport.saveToExcel(filePath, "Degree Centrality");
stringReport.saveToExcelAttachRight(filePath,"Degree Centrality", 2);
An original string table (red) and a new string table (blue) separated by a margin
Note Caveat #1: the file path provided in the above example is applicable only
if you have installed NetMiner 4 at the default path.
96
saveToExcelAttachBottom
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function saves a string table as an Excel file. If there is an Excel
file with the same name, a string table will be appended to the bottom
of an existing content with a margin specified by a user.
Syntax thisStringTable.saveToExcelAttachBottom ( filepath , sheetName, [ margin ] )
Input filepath (String) : the file path and the name of an Excel file to be
Parameter created.
sheetName (String) : the sheet name of an Excel file to be created.
margin (int) : the space between an existing content and a new string
table. The default value is 2.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
filePath = r"%UserProfile%\NetMiner
\SampleData\Cyram Dataset
\01.Org_Net_Tiny1\excelSample.xls";
stringReport.saveToExcel(filePath, "Degree Centrality");
stringReport.saveToExcelAttachBottom(filePath,"Degree Centrality", 2);
Note Caveat #1: the file path provided in the above example is applicable only
if you have installed NetMiner 4 at the default path.
saveToCSV
Dependency StringTable
97
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function saves a string table to a csv file. If there is a csv file with
the same name, the existing file will be replaced with the csv file
generated by this function.
Syntax thisStringTable.saveToCSV ( filepath )
Input filepath (String) : the file path and the name of a csv file to be created.
Parameter
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
filePath = r"%UserProfile%\NetMiner\SampleData\Cyram Dataset
\01.Org_Net_Tiny1\CSVSample.csv";
stringReport.saveToCSV(filePath);
Note Caveat #1: the file path provided in the above example is applicable only
if you have installed NetMiner 4 at the default path.
98
saveToCSVAttachRight
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function saves a string table as a csv file. If there is a csv file with
the same name, a string table will be appended to the right side of an
existing content with a margin specified by a user.
Syntax thisStringTable.saveToCSVAttachRight ( filepath, [ margin ] )
Input filepath (String) : the file path and the name of a csv file to be created.
Parameter margin (int) : the space between an existing content and a new string
table. The default value is 2.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
filePath = r"%UserProfile%\NetMiner\SampleData\Cyram Dataset
\01.Org_Net_Tiny1\CSVSample.csv";
stringReport.saveToCSV(filePath);
stringReport.saveToCSVAttachRight(filePath, 2);
Note Caveat #1: the file path provided in the above example is applicable only
if you have installed NetMiner 4 at the default path.
99
saveToCSVAttachBottom
Dependency StringTable
Description This function is accessible through a stringtable object using the dot
notation (e.g. object.function()).
This function saves a string table as a csv file. If there is a csv file with
the same name, a string table will be appended to the bottom of an
existing content with a margin specified by a user.
Syntax thisStringTable.saveToCSVAttachBottom ( filepath, [ margin ] )
Input filepath (String) : the file path and the name of a csv file to be created.
Parameter margin (int) : the space between an existing content and a new string
table. The default value is 2.
Return Value None
Example session1 = _NM.Session.openSession("Degree Centrality");
report = session1.getTableReport("[T] Degree Centrality Vector");
stringReport = report.getStringTable();
filePath = r"%UserProfile%\NetMiner\SampleData\Cyram Dataset
\01.Org_Net_Tiny1\CSVSample.csv";
stringReport.saveToCSV(filePath);
stringReport.saveToCSVAttachBottom(filePath, 2);
Note Caveat #1: the file path provided in the above example is applicable only
if you have installed NetMiner 4 at the default path.
100
3 Matrix Data Handling
3.1 Creating a matrix
identityMatrix
Dependency _MAT.Create
Description This function creates an identity matrix of size N (i.e. N by N square
matrix) that has 1s on the main diagonal and 0s elsewhere.
Syntax thisMatrix = _MAT.Create.identityMatrix ( size )
Input size (int) : the size of a matrix (i.e. specifying the N)
Parameter
Return Value thisMatrix (matrix) : a matrix object
Example matrix = _MAT.Create.identityMatrix(5);
print matrix;
zeroMatrix
Dependency _MAT.Create
Description This function creates a blank matrix (or a zero matrix) of a size specified
by a user.
Syntax thisMatrix = _MAT.Create.zeroMatrix ( rowSize , columnSize )
Input rowSize (int) : the row size of a matrix.
Parameter columnSize (int) : the column size of a matrix.
Return Value thisMatrix (matrix) : a matrix object
Example matrix = _MAT.Create.zeroMatrix(3, 5);
print matrix;
randomMatrix
Dependency _MAT.Create
Description This function creates a new matrix, which has the entries ranging from 0 to
1 (i.e. randomly generated).
101
Syntax thisMatrix = _MAT.Create.randomMatrix ( rowSize , columnSize )
Input rowSize (int) : the row size of a matrix.
Parameter columnSize (int) : the column size of a matrix.
Return Value thisMatrix (matrix) : a matrix object
Example Matrix = _MAT.Create.randomMatrix(3 , 3);
print matrix;
diagonalMatrix
Dependency _MAT.Create
Description This function creates an N by N square matrix whose main diagonal is a
vector specified by a user.
Syntax thisMatrix = _MAT.Create.diagonalMatrix ( diagonalVector )
Input diagonalVector (matrix) : an N by 1 matrix used to set the diagonal
Parameter entries of a N by N square matrix.
Return Value thisMatrix (matrix) : a matrix object
Example vectorMatrix = _MAT.Create.zeroMatrix(3 , 1);
vectorMatrix.setElement(0 ,0, 1);
vectorMatrix.setElement(1, 0, 2);
vectorMatrix.setElement(2, 0, 3);
print vectorMatrix;
matrix = _MAT.Create.diagonalMatrix( vectorMatrix);
print matrix;
102
copy
Dependency Matrix
Description This function creates a duplicate for the current matrix.
Syntax matrix1 = thisMatrix.copy( )
Input None
Parameter
Return Value matrix1 (matrix) : a duplicate for the current matrix.
Example matrix1 = _MAT.FromNM.get1modeNetwork("work interact");
matrix2 = matrix1.copy();
103
3.2 NetMiner workfile Get and Add
getMainNodeAttribute
Dependency _MAT.FromNM
Description This function generates an N by 1 matrix, whose entries consist of the
values from a specified main node attribute.
Syntax thisMatrix = _MAT.FromNM.getMainNodeAttribute( attName )
Input attName (String) : the name of an attribute in the main nodeset.
Parameter
Return Value thisMatrix (matrix) : a matrix object
Example matrix = _MAT.FromNM.getMainNodeAttribute("Gender");
Note If the type of attribute values is not a number, their type will be changed to
a number based on the index of each value. As to a String type, entries
with the same String value will have the same number.
104
getSubNodeAttribute
Dependency _MAT.FromNM
Description This function generates an N by 1 matrix, whose entries consist of the
values from a specified sub nodeset attribute.
Syntax thisMatrix = _MAT.FromNM.getSubNodeAttribute( nodeSetName, attName )
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
get1modeNetwork
Dependency _MAT.FromNM
Description This function generates an N by N matrix, whose entries consist of the
values from a 1-mode network.
N is the size of a main nodeset.
Syntax thisMatrix = _MAT.FromNM.get1modeNetwork ( networkName )
Input networkName (String) : the name of a 1-mode network from which
Parameter entries of the matrix generated by this function are chosen.
Return Value thisMatrix (matrix) : a matrix object
Example matrix = _MAT.FromNM.get1modeNetwork("work interact");
Note Caveat: the input parameter of the above example is only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
get2modeNetwork
Dependency _MAT.FromNM
105
Description This function generates an N by M matrix, whose entries consist of the
values from a 2-mode network.
N is the size of a main nodeset and M is the size of a sub nodeset.
Syntax thisMatrix = _MAT.FromNM.get2modeNetwork ( nodeSetName , networkName )
Input nodeSetName (String) : the name of a sub nodeset that forms the part
Parameter of a 2-mode network.
networkName (String) : the name of a 2-mode network formed with
the sub nodeset specified as an input parameter (i.e. nodeSetName).
Return Value thisMatrix (Matrix) : a matrix object
Example matrix = _MAT.FromNM.get2modeNetwork("Clubs", "Club Affiliation");
Note Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
106
addToMainNodeAttribute
Dependency Matrix
Description This function adds a vector matrix to a main nodeset as its attribute.
Syntax thisMatrix.addToMainNodeAttribute ( attName )
Input attName (String) : the name of an attribute, which is to be added as an
Parameter attribute of a main nodeset.
Return Value None
Example matrix1 = _MAT.Create.zeroMatrix(22,1);
matrix1.addToMainNodeAttribute(“matrixAttribute”);
Note The type of an attribute generated by this function is a number. An
attribute will be replaced by the attribute this function generates if these
attributes share the same name.
107
addToSubNodeAttribute
Dependency Matrix
Description This function adds a vector matrix to a sub nodeset as an attribute.
Syntax thisMatrix.addToSubNodeAttribute ( nodeSetName , attName )
Input nodeSetName (String) : the name of a sub nodeset to which an
Parameter attribute generated by this function will be added.
attName (String) : the name of an attribute, which is to be added as an
attribute of a sub nodeset.
Return Value None
Example matrix1 = _MAT.Create.zeroMatrix(3, 1);
matrix1.addToSubNodeAttribute("Clubs", "matrixAttribute");
Note The type of an attribute generated by this function is a number. An
attribute will be replaced by the attribute this function generates if these
attributes share the same name.
Caveat: the input parameters of the above example are only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
108
addTo1modeNetwork
Dependency Matrix
Description This function adds a matrix as a 1-mode network to a workfile.
This function only runs for an N by N square matrix where N is the
size of a main nodeset.
Syntax thisMatrix.addTo1modeNetwork ( networkName )
Input networkName (String) : the name of a 1-mode network created by this
Parameter function.
Return Value None
Example matrix1 = _MAT.Create.zeroMatrix(22, 22);
x = 0;
for i in range(matrix1.getRowSize()):
for j in range(matrix1.getColumnSize()):
matrix1.setElement(i, j, x);
x+= 1;
print matrix1;
matrix1.addTo1modeNetwork("matrixNetwork1");
Note An existing 1-mode network will be replaced by the 1-mode network this
function generates if these networks share the same name.
109
addTo2modeNetwork
Dependency Matrix
Description This function adds a matrix as a 2-mode network to a workfile.
This function only runs for an N by M matrix where N is the size of a
main nodeset and M is the size of a sub nodeset.
Syntax thisMatrix.addTo2modeNetwork ( nodeSetName, networkName )
Input nodeSetName (String) : the name of a sub nodeset that forms the
Parameter part of a 2-mode network.
networkName (String) : the name of a 2-mode network created by
this function.
Return Value None
Example matrix1 = _MAT.Create.zeroMatrix(22, 3);
x = 0;
for i in range(matrix1.getRowSize()):
for j in range(matrix1.getColumnSize()):
matrix1.setElement(i, j, x);
x+= 1;
print matrix1;
matrix1.addTo2modeNetwork("Clubs","matrixNetwork");
Note An existing 2-mode network will be replaced by the 2-mode network this
function generates if these networks share the same name.
110
addToLinkAttribute
Dependency Matrix
Description This function adds a matrix as a link attribute of a network.
The type of a link attribute generated by this function is a number.
As to 2-mode networks, this function runs for an N by M matrix
where N is the size of a main nodeset and M is the size of a sub
nodeset.
As to 1-mode networks, this function runs for an N by N square
matrix where N is the size of a main nodeset.
Syntax thisMatrix.addToLinkAttribute ( networkName , attName )
Input networkName (String) : the name of a network to which a matrix will
Parameter be added as an link attribute.
attName (String) : the name of a link attribute to be added.
Return Value None
Example matrix1 = _MAT.Create.zeroMatrix(22, 22);
matrix1.addToLinkAttribute("work interact", "linkAttribute");
111
3.3 Matrix
getElement
Dependency Matrix
Description This function returns the value of a matrix whose location will be specified
by a user through input parameters (i.e. row and column name).
Syntax element = thisMatrix.getElement ( row , column )
Input row (int) : the row index of a matrix.
Parameter column (int) : the column index of a matrix.
Return Value element (double) : the value from specified row and column.
112
getColumnVector
Dependency Matrix
Description This function returns the values of a specified column in the form of an N
by 1 vector matrix.
Syntax vector = thisMatrix getColumnVector ( columnIndex )
Input columnIndex (int) : the index of a column.
Parameter
Return Value vector (matrix) : an N by 1 vector matrix.
Example matrix = _MAT.Create.identityMatrix(4);
column = matrix.getColumnVector(0);
print column;
Note While the index of a first column is 0, the index of a last column is N-1.
getRowVector
Dependency Matrix
Description This function returns the values of a specified row in the form of an N by 1
vector matrix.
Syntax vector = thisMatrix getRowVector ( rowIndex )
Input rowIndex (int) : the index of a row.
Parameter
Return Value vector (matrix) : an N by 1 vector matrix.
Example matrix = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix.getRowSize()):
for j in range(matrix.getColumnSize()):
matrix.setElement(i, j, x); .
x += 1;
print matrix;
getrow = matrix.getRowVector(1);
print getrow;
Note While the index of a first row is 0, the index of a last row is N-1.
113
getDiagonalVector
Dependency Matrix
Description This function returns the diagonal values of a square matrix in the form of
an N by 1 vector matrix.
Syntax vector = thisMatrix.getDiagonalVector( )
Input None
Parameter
Return Value vector (matrix) : an N by 1 diagonal vector matrix.
Example matrix = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix.getRowSize()):
for j in range(matrix.getColumnSize()):
matrix.setElement(i, j, x);
x += 1;
diagonal = matrix.getDiagonalVector();
print diagonal;
getRowSize
Dependency Matrix
Description This function returns the row size of a matrix.
Syntax rowSize = thisMatrix.getRowSize( )
Input None
Parameter
Return Value rowSize (int) : the row size of a matrix.
Example matrix = _MAT.Create.identityMatrix(5);
rowsize = matrix.getRowSize();
print rowsize;
114
getColumnSize
Dependency Matrix
Description This function returns the column size of a matrix.
Syntax colSize = thisMatrix.getColumnSize( )
Input None
Parameter
Return Value colSize (int) : the column size of a matrix.
Example matrix = _MAT.Create.zeroMatrix(3, 4);
colsize = matrix.getColumnSize();
print colsize;
getMatrixSize
Dependency Matrix
Description This function returns the size of a matrix, which is the product of a row
size and a column size.
Syntax size = thisMatrix.getMatrixSize( )
Input None
Parameter
Return Value size (int) : the product of a row size and a column size.
Example matrix = _MAT.Create.zeroMatrix(3, 4);
size = matrix.getMatrixSize();
print size;
115
getMatrixSum
Dependency Matrix
Description This function returns the sum of all entries in a matrix.
Syntax matrixSum = thisMatrix.getMatrixSum( )
Input None
Parameter
Return Value matrixSum (double) : the sum of all entries in a matrix
Example matrix = _MAT.Create.identityMatrix(4);
matrix.setElement(1,2,1);
sum = matrix.getMatrixSum();
print sum;
getColumnSum
Dependency Matrix
Description This function returns an N by 1 matrix whose entries are the sum of each
column of a matrix.
Syntax colSumVector = thisMatrix.getColumnSum( )
Input None
Parameter
Return Value colSumVector (double) : the sum of each column represented as an N by 1
vector matrix (e.g. three columns would return three sum results).
Example matrix = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix.getRowSize()):
for j in range(matrix.getColumnSize()):
matrix.setElement(i, j, x);
x += 1;
colSum = matrix.getColumnSum();
print colSum;
Note Alternatively, you can directly find out the indegree of a network.
116
getRowSum
Dependency Matrix
Description This function returns an N by 1 matrix whose entries are the sum of each
row of a matrix.
Syntax rowSumVector = thisMatrix.getRowSum( )
Input None
Parameter
Return Value rowSumVector (double) : the sum of each row represented as an N by 1
vector matrix (e.g. three rows would return three sum results).
Example matrix = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix.getRowSize()):
for j in range(matrix.getColumnSize()):
matrix.setElement(i, j, x);
x += 1;
rowSum = matrix.getRowSum();.
print rowSum;
Note Alternatively, you can directly find out the outdegree of a network.
117
getLowerSum
Dependency Matrix
Description This function returns the sum
of values situated on the lower
half of a square matrix centered
on a diagonal.
118
getUpperSum
Dependency Matrix
Description This function returns the sum
of values situated on the upper
half of a square matrix centered
on a diagonal.
119
trace (or getDiagonalSum)
Dependency Matrix
Description This function returns the trace (i.e. the sum of diagonal values) value of a
matrix.
Syntax diagonalSum = thisMatrix.trace( ) or thisMatrix.getDiagonalSum( )
Input None
Parameter
Return Value diagonalSum (double) : the trace (i.e. the sum of diagonal values) value of
a matrix.
Example matrix = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix.getRowSize()):
for j in range(matrix.getColumnSize()):
matrix.setElement(i, j, x);
x += 1;
trace = matrix.trace(); #or matrix.getDiagonalSum();
print trace;
getCardinality
Dependency Matrix
Description This function returns the number of entries that contain values other than 0
Syntax cardinality = thisMatrix.getCardinality ( )
Input None
Parameter
Return Value cardinality (int) : the number of entries that contain values other than 0
Example matrix = _MAT.Create.identityMatrix(5);
cardinality = matrix.getCardinality();
print cardinality;
120
setElement
Dependency Matrix
Description This function changes the value from specified row and column.
Syntax thisMatrix.setElement ( row , column , valueNew )
Input row (int) : the index of a row.
Parameter column (int) : the index of a column.
valueNew (double) : a new value for an entry, which can be found at
the specified row and column.
Return Value None
Example matrix = _MAT.Create.zeroMatrix(3, 3);
matrix.setElement(0 , 0, 1);
print matrix;
setZeros
Dependency Matrix
Description This function changes every value of a matrix to 0.
Syntax thisMatrix.setZeros( )
Input None
Parameter
Return Value None
Example matrix = _MAT.FromNM.get1modeNetwork("work interact");
print matrix;
matrix.setZeros();
print matrix;
Note Caveat: the input parameter of the above example is only applicable
when ’01. Org_Net_Tiny1.nmf’ is opened.
121
dichotomize
Dependency Matrix
Description This function returns a matrix, which is the result of dichotomizing a
matrix specified by a user.
Syntax dichoMatrix = thisMatrix.dichotomize( [ threshold ] )
Input threshold (double) : the value of a threshold value. The default value is 0.
Parameter
Return Value dichoMatrix (matrix) : a dichotomized matrix
Example matrix = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix.getRowSize()):
for j in range(matrix.getColumnSize()):
matrix.setElement(i, j, x);
x += 1;
dichotomizedMatrix = matrix.dichotomize();
print dichotomizedMatrix;
122
symmetrize
Dependency Matrix
Description This function returns a matrix, which is the result of symmetrizing a
matrix specified by a user.
123
transpose
Dependency Matrix
Description This function returns a matrix, which is the result of transposing a matrix
specified by a user.
inverse
Dependency Matrix
Description This function returns a matrix, which is the result of inversing a matrix
specified by a user.
124
elemWiseMult
Dependency Matrix
Description This function returns a matrix, which is the result of computing an element
wise multiplication between the matrix provided as an input parameter and
other existing matrix.
Syntax elemMatrix = thisMatrix.elemWiseMult( matrix )
Input matrix (matrix) : the name of a matrix to be element-wisely multiplied
Parameter with an existing matrix.
Return Value elemMatrix (matrix) : a matrix, which is the result of computing an
element wise multiplication between the matrix provided as an input
parameter and other existing matrix.
Example matrix1 = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix1.getRowSize()):
for j in range(matrix1.getColumnSize()):
matrix1.setElement(i, j, x);
x += 1;
matrix2 = matrix1.copy();
wiseMult = matrix1.elemWiseMult(matrix2);
print wiseMult;
Note An element wise multiplication is not about computing a dot product
between matrices. Rather, an (i, j) element of the matrix, which is the
result of this function, would have its value by multiplying the value from
an (i, j) element of a matrix, with the value from an (i, j) element of
another matrix (i.e. Ai, j * Bi, j).
125
elemWiseDiv
Dependency Matrix
Description This function returns a matrix, which is the result of computing an element
wise division between the matrix provided as an input parameter and other
existing matrix.
Syntax elemMatrix = thisMatrix.elemWiseDiv( matrix )
Input matrix (matrix) : the name of a matrix that is to be element-wisely
Parameter divided with an existing matrix.
Return Value elemMatrix (matrix) : a matrix, which is the result of computing an
element wise division between the matrix provided as an input parameter
and other existing matrix.
Example matrix1 = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix1.getRowSize()):
for j in range(matrix1.getColumnSize()):
matrix1.setElement(i, j, x);
x += 1;
matrix2 = matrix1.copy();
wiseDiv = matrix1.elemWiseDiv(matrix2);
print wiseDiv;
Note An element wise division is not about computing a division between
matrices. Rather, an (i, j) element of the matrix, which is the result of this
function, would have its value by dividing the value from an (i, j) element
of a matrix, with the value from an (i, j) element of another matrix (i.e. Ai, j
/ Bi, j).
126
elemWisePow
Dependency Matrix
Description This function returns a matrix, which is the result of computing an element
wise power by raising the elements in a matrix to the corresponding power
provided as an input parameter.
Syntax elemMatrix = thisMatrix.elemWisePow( pow )
Input pow (int) : an element wise power value
Parameter
Return Value elemMatrix (matrix) : a matrix, which is the result of computing an
element wise power by raising the elements in a matrix to the
corresponding power provided as an input parameter.
Example matrix1 = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix1.getRowSize()):
for j in range(matrix1.getColumnSize()):
matrix1.setElement(i, j, x);
x += 1;
wisePow = matrix1.elemWisePow(2);
print wisePow;
Note An element wise power is about raising an (i, j) element of a matrix to the
corresponding power (i.e. 𝐴𝑝𝑜𝑤
𝑖𝑗 )
127
isSymmetric
Dependency Matrix
Description This function determines whether a matrix is symmetrized or not.
isDichotomized
Dependency Matrix
Description This function determines whether a matrix is dichotomized or not.
getFullIterator
Dependency Matrix
128
Description This function creates an iterator that iterates through an entire matrix.
During iteration, elements with the value of 0 are skipped.
129
getRowIterator
Dependency Matrix
Description This function creates an iterator that iterates through a particular row of a
matrix. During iteration, elements with the value of 0 are skipped.
130
next
Dependency Iterator
Description This function returns the next value starting from the first value in a
matrixIterator object. Along with the value stored in each entry, the
function also returns information about its position (i.e. corresponding row
and column index)
Syntax data = thisIterator.next ( )
Input None
Parameter
Return Value data (Object [ ]) : a list of objects that takes the form of [row index,
column index, value]
Example matrix = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix.getRowSize()):
for j in range(matrix.getColumnSize()):
matrix.setElement(i, j, x);
x += 1;
iter = matrix.getFullIterator();
print iter.next();
print iter.next();
print iter.next();
131
hasnext
Dependency Iterator
Description This function determines whether the next value starting from the first
value in a matrixIterator object exists or not. If a next value does not exist,
the function returns ‘True.’ Otherwise, it returns ‘False.’
Syntax hasData = thisIterator.hasnext( )
Input None
Parameter
Return Value hasData (Boolean) : If a next value exists, the value is True. Otherwise, the
value is False.
Example matrix = _MAT.Create.zeroMatrix(3, 3);
x = 0;
for i in range(matrix.getRowSize()):
for j in range(matrix.getColumnSize()):
matrix.setElement(i, j, x);
x += 1;
iter = matrix.getFullIterator();
while(iter.hasNext()):
print iter.next();
132
4 Dialog Handling
4.1 File Dialog
openFileOpenDialog
Dependency _SYS.Dialog
Description This function creates a ‘file open’ dialog box and returns the file path and
its file name designated by a user.
133
openFileSaveDialog
Dependency _SYS.Dialog
Description This function creates a ‘file save’ dialog box and returns the file path and
its file name designated by a user.
134
4.2 Directory Dialog
openDirectoryDialog
Dependency _SYS.Dialog
Description This function creates a ‘directory selection’ dialog box.
135
4.3 Custom Dialog
createCustomDialog
Dependency _SYS.Dialog
Description This function creates a customdialog object that has a series of options
used to get an input from a user.
Input title (String) : the title of a dialog box. The default value is ‘Input
Parameter Dialog.’
message (String) : the message to be printed in a dialog box. If
omitted, no message will be printed.
Return Value thisCustomDialog (customdialog) : a customdialog object.
Example customDialog = _SYS.Dialog.createCustomDialog("Title", "Message");
customDialog.open();
Note For NetMiner to activate a dialog, which would allow a user to supply an
input, an open function (i.e. open() ) must be utilized.
addComboBoxVariable
Dependency CustomDialog
Description This function adds a combo box, which allows a user to choose from a list
of existing options by scrolling, to a dialog.
136
addDirectoryVariable
Dependency CustomDialog
Description This function adds an input directory, which would be used for a user to
select a specific folder.
addFileOpenVariable
Dependency CustomDialog
Description This function adds an option allowing a user to specify the path of a file to
be opened.
137
addFileSaveVariable
Dependency CustomDialog
Description This function adds an option allowing a user to specify the path of a file to
be saved.
addIntegerVariable
Dependency CustomDialog
Description This function adds an option allowing a user to provide an input with a
value in integer.
138
addRealVariable
Dependency CustomDialog
Description This function adds an option allowing a user to provide an input with a
real number.
addStringVariable
Dependency CustomDialog
Description This function adds an option allowing a user to provide an input with a
String value.
139
open
Dependency CustomDialog
Description This function opens up a dialog that allows a user to provide an input
value. If a user clicks an OK button after providing an input(s) through an
available option(s), this function returns a list of input values supplied by a
user.
Syntax result = thisCustomDialog.open ( )
Input None
Parameter
Return Value result (Object [ ]) : an array list of input variables. A list is ordered based
on the order of options. If a user clicks Cancel button, this function returns
‘None.’
Example dialog = _SYS.Dialog.createCustomDialog("Title", "Message");
dialog.addIntegerVariable("variable1",0);
dialog.addIntegerVariable("variable2",1);
result = dialog.open();
140
4.4 Message Box
openMessageBox
Dependency _SYS.Dialog
Description This function opens up a message box with a specified message.
141
4.5 HTML Dialog
openHtmlDialog
Dependency _SYS.Dialog
Description This function opens up a dialog as an html file. The script continues to run
after activating the dialog.
142
4.6 Status Dialog
showStatusDialog
Dependency _SYS.Dialog
Description This function opens up a status dialog that displays current status. In other
words, while the script is running, this dialog displays the progress of the
script.
Syntax _SYS.Dialog. showStatusDialog ( [ status ] )
Input status (String) : can be used to set how the progress would be displayed
Parameter on the status dialog.
Return Value None
Example mat = _MAT.FromNM.get1modeNetwork('work interact');
for i in range(10000):
mat2 = mat * mat;
_SYS.Dialog.showStatusDialog('aaaaa'+str(i));
Note If a user clicks Cancel button on the status dialog, a script would stop
running, which is equivalent to using a stop( ) function. Even if an input
parameter is ‘None’, a script would continue to run but a user would not
be able to check the progress.
143
closeStatusDialog
Dependency _SYS.Dialog
Description This function closes a status dialog.
Syntax _SYS.Dialog.closeStatusDialog ( )
Input None
Parameter
Return Value None
Example mat = _MAT.FromNM.get1modeNetwork('work interact');
for i in range(10000):
if i < 5000:
mat2 = mat * mat;
_SYS.Dialog.showStatusDialog('aaaaa' + str(i));
else:
mat2 = mat * mat;
_SYS.Dialog.closeStatusDialog();
Note If a user clicks Cancel button on the status dialog, a script would stop
running, which is equivalent to using a stop( ) function.
144
5 Script Controlling
pause
Dependency _SYS.Script
Description This function arbitrarily stops a script and opens a dialog to ask a user
whether to continue or not. While a dialog is active, a user can work on
other things in NetMiner.
Syntax _SYS.Script.pause ( )
Input None
Parameter
Return Value None
Example _SYS.Script.pause();
stop
Dependency _SYS.Script
Description This function stops a script. If this function is called, any script after this
function would stop running.
145