@graphty/graph-io / @graphty/graph-io / TextCellWriter
Class: TextCellWriter ​
Defined in: common/text.ts:153
Writes the cells of one attribute of a text format whose values carry no type (CSV, DOT, Pajek): you hand it each cell's text and it stores a number, a boolean or text, choosing one type for the whole attribute. A column of 2.0, 3.5 stays a number column with decimals even though 2.0 alone looks like an integer, and once one cell turns out to be text, earlier cells such as 1e5 are kept as written instead of as 100000. Create one writer per attribute name and per kind ("node" or "edge"), and call write(index, text) with the node or edge index the sink gave you:
const color = new TextCellWriter("color", "node", sink, report);
color.write(sink.addNode("a"), "red");A sink that cannot change a column's type after the fact (one of your own without widenNodeColumn / widenEdgeColumn) keeps the type the first values implied, with one W_WIDENING_UNSUPPORTED warning per attribute.
Constructors ​
Constructor ​
new TextCellWriter(
name,domain,sink,report):TextCellWriter
Defined in: common/text.ts:182
Create a writer. The attribute is added to the sink on the first write.
Parameters ​
name ​
string
the attribute name
domain ​
"edge" | "node"
"node" for a node attribute, "edge" for an edge attribute
sink ​
GraphSink
the sink the importer fills
report ​
the import report, for warnings about the values
Returns ​
TextCellWriter
Properties ​
name ​
readonlyname:string
Defined in: common/text.ts:155
The column name in the sink.
Accessors ​
column ​
Get Signature ​
get column():
ColumnHandle
Defined in: common/text.ts:193
The sink's handle of the attribute's column, for reading it back.
Returns ​
ColumnHandle
the handle, or INVALID_INDEX before the first write
Methods ​
write() ​
write(
row,text):void
Defined in: common/text.ts:202
Write one cell.
Parameters ​
row ​
number
the node or edge index, as the sink's addNode() or addEdge() returned it
text ​
string
the cell text, exactly as read from the file
Returns ​
void