**6. Yarn Order Visualization**

The algorithms presented in Section 5 describe how the ordering of stacked CNs, and, therefore, yarn loops, is determined for a knitted fabric. This ordering information, provided by the execution of the YARN\_ORDER function, has been incorporated into TopoKnit's yarn topology graph visualization algorithm (Algorithm 7 (DRAW\_TOPOLOGY\_GRAPH) in Kapllani et al. [1]) in the form of textual data. Examples of these visualizations are provided in the yarn topology graphs in Figures 11c, 13c and 17c. In each (*i*, *j*) location in the graphs where at least one CN is present, labels corresponding to the CN order are

added. In locations where there are more than one CN, the displayed bottom-to-top order of the CNs corresponds to the order of yarns from front to back.

**Figure 17.** Stitch pattern with a combination of Knit, Purl, Front and Back Transfer, Front Miss, and Front and Back Tuck stitches: (**a**) Stitch instructions. (**b**) Simulated knitted pattern. (**c**) Topology graph displaying CN (loop) order.

### *Zoom-in Visualizations*

Using textual data to convey loop ordering may not be ideal for all scenarios or users. Therefore, Algorithm 6 was developed to display a zoom-in view of the stacked loops that go through location (*i*, *j*), using color instead of textual data to present ordering information. The zoom-in graphs presented in this paper use three colors, where the red loop represents the front loop, the green loop represents the middle loop, and the blue loop represents the back loop. We chose three colors based on the assumption that three is the maximum number of loops a needle can hold without breaking, as described in [2]. Algorithm 6 can be easily modified for a different assumption, i.e., the needle can hold more than three loops, by adding colors to the *yarnColors* variable accordingly. An example of a zoom-in graph is given in Figure 15b. This figure displays loop ordering at locations (6, 5) and (7, 5) for the yarn topology graph presented in Figure 11c.

To create a zoom-in graph, the list of ordered CNs at location (*i*, *j*) is generated and a yarn color is assigned to each depending on its order position. The zoom-in graph draws the corresponding loop for each CN in their specified order. To ensure that intersections between pairs of yarns are correctly ordered visually, the list of CNs is reversed. Thus, the loops are drawn in a back-to-front order. See Lines 1–7 in Algorithm 6.


To identify and draw the loops, Algorithm 6 makes use of algorithms from the previous Kapllani et al. work, specifically Algorithm 1 (FOLLOW\_THE\_YARN) [1] and a modified version of Algorithm 12 (DEFINE\_OPEN\_LOOPS) [2]. The FOLLOW\_THE\_YARN algorithm returns a yarn path, which is an ordered list of locations that the yarn passes through

as it flows through the fabric grid. Each node of the yarn path has three elements: the list of CNs (CNL) that are engaged in the yarn intertwining at the associated final location (*i*, *j*) (FL), and the current stitch row (CR). The modified DEFINE\_OPEN\_LOOPS algorithm returns a set of open loops that are extracted from the yarn path (Lines 8 and 9). An open loop is a portion of the yarn path that begins and ends on the same fabric row. See Figure 11 in Kapllani et al. [2] for an example. The algorithm returns three variables: *loops*, *edgeLoopPair*, and *indexLoopPair*. The variable *loops* is a list of lists where each inner list contains the CNs and their final locations that make up a loop. Each open loop consists of four or more CNs, two of which are head CNs. The CNs define one head edge (a connection between two head CNs) and two or more leg edges (a connection between two leg CNs or a leg CN and a head CN). See Figure 16. The *edgeLoopPair*, and *indexLoopPair* variables are both dictionaries storing edge-loop index and loop index-loop pairs, respectively.

The algorithm goes through the CNs that end up at location (*i*, *j*) (Line 10) and draws the corresponding loop with the CNs that make up each loop. It is possible for YARN\_ORDER\_ZOOM\_IN to be called at a location with no ACNs (yarn intertwinings) but with just an unanchored CN (UACN). Here, the index into the yarn path (YPI), which only stores actualized CNs (ACNs), is "null" (Line 13). In this case, the head edge through location (*i*, *j*) is retrieved from the data structure, with the function FIND\_HEAD\_EDGE (Line 14) and one of its head CNs is placed in the list *colorOrderedCNs* (Line 15), which guarantees that the loop through the UACN is drawn. An example of this situation is the green loop in Figure 18, with the UACNs displayed with gray squares, which is a zoom-in of CNs (5, 3) and (6, 3) in Figure 17.

**Figure 18.** Yarn order zoom-in at location (5, 3) in the yarn topology graph of Figure 17: (**a**) Simulated knitted pattern. (**b**) Corresponding zoom-in topology graph.

Figure 3. Survival outcomes between standard versus high risk patients. **Figure 3.** Survival outcomes between standard versus high risk patients. The CNs that make up a loop are extracted in Lines 17 through 32. Note that the CNs that end up at location (*i*, *j*) are head CNs, and using the index of the current CN in the yarn path (YPI), we can retrieve the previous and next CNs in the path, one of which is a head CN and the other a leg CN. Knowing the parity of the *i* component of the CN and its current row, we can determine which is the head CN and which is the leg CN. See Lines for 22–32. Since head CNs can move/shift vertically and horizontally, different loops can have overlapping head edges. The connection between the processed CN and its adjacent leg CN is used as the identifying edge to determine the loop. Thus to uniquely identify a loop,

death, HR 0.49 (95% CI 0.38–0.62), and 0.53 (95% CI 0.40–0.69).

Furthermore, the rate of response both pre- and post-transplant showed statistically significant improvement across the years (*p* < 0.01). The post-transplant response (VGPR or better) also increased from 28.9% in group 1 to 76.3% in group 5 (Table 1). Multivariable analysis showed that transplant year, pre-transplant remission status, International Staging

2009–2013 and between 2014–2016 had a significantly lower risk for relapse or death, HR

**Table 2.** Cox Proportional Hazard Model on Risk of Relapse or Death.

Age > 65 0.90 0.74 1.09 0.296

Female 0.98 0.85 1.14 0.824

White 1.01 0.82 1.25 0.923 Others 0.63 0.26 1.54 0.308

**Characteristics HR 95% CI** *p***-Value** 

Transplant year 2009—2013 0.48 0.40 0.57 <0.001 Transplant year 2014—2016 0.52 0.42 0.63 <0.001 Age at ASCT 1.00 0.99 1.01 0.814 Age ≤ 65 Reference

Male Reference

Black Reference

140 Reference

Furthermore, the rate of response both pre- and post-transplant showed statistically

analysis showed that transplant year, pre-transplant remission status, International Staging System (ISS), and high- versus standard-risk cytogenetics have significant contributions to the risk of relapse or death (Tables 2 and 3). Patients who received transplant between 2009–2013 and between 2014–2016 had a significantly lower risk for relapse or

0.49 (95% CI 0.38–0.62), and 0.53 (95% CI 0.40–0.69).

Transplant year ≤ 2008 Reference

Univariable model Transplant year

Melphalan dose (mg/m2)

Gender

Race

a leg edge is used to determine the index in the *edgeLoopPair* dictionary. See Lines 28 and 32. The loop index can then be used to extract the list of CNs that make up the loop in the *indexLoopPair* dictionary (Line 33).

Once the CNs of the current loop have been identified, Algorithm 6 draws the loop's edges. Specifically, lines 35–36 are responsible for drawing the connections between CNs of the loop (loop edges) and lines 37–47 are responsible for drawing the CN icons of the loop. In Lines 37 through 41, the color of the ACN icon is determined, with Knit stitches colored gray and Purl stitches colored green. The commands in Lines 43 through 47 iterate through the locations along the head edge and draw a gray square at locations containing a UACN.

#### **7. Testing and Results**

The correctness of the algorithms presented in this paper was evaluated by comparing our results to the graphical outputs from the Shima Seiki SDS-One APEX3 KnitPaint and KnitDesign systems. The input precedence rules were extracted by observing the simulation of 200 6 × 6 stitch patterns within the Shima software. Thus, we would expect the loop stacking order defined by the algorithms to match the Shima simulations. Specifically, we analyzed 100 random 6 × 6 stitch patterns, 50 of which were a combination of Knit, Purl, and Front and Back Transfer stitches and 50 which added Front and Back Tuck stitches to the original combination. For each group of 50, half of the patterns produced fabric locations with a maximum of two overlapping yarn loops and half had a maximum of three overlapping loops at a specific location (*i*, *j*). The ordering of CNs produced by our algorithms at each location for all of the tested patterns matched the order of loops in the Shima simulation outputs. Some of these test examples are described below.

Figures 11c, 13c and 17c show topology graphs corresponding to the stitch patterns in Figures 11a, 13a and 17a, respectively. In Figure 11c, three CNs end up at location (6, 5), where CN (6, 5) is in front, followed by CN (8, 5) in the middle, and CN (4, 5) is at the back. Looking at the fabric, we would see the loop created by the Knit stitch first, followed by the loop created by the Back Transfer Left (BXL) stitch, followed by the loop created by the Back Transfer Right (BXR) stitch, which is what is seen in the simulation created by Shima Seiki SDS-OneAPEX3 KnitDesign software in Figures 11b and 15a. Similarly, two CNs end up at location (6, 4) in Figure 17c, where CN (4, 5) is in front, followed by CN (6, 4). The simulation in Figure 17b also confirms this ordering with the loop created by the Front Transfer Right (FTX) first, followed by the Purl stitch. Note that the labeled CNs can have ACN or UACN actualization values. For instance, three CNs end up at location (5, 3) in Figures 17c and 18a, one UACN (5, 3) (visualized with a gray square), and two ACNs ((5, 2) and (9, 3)). Figure 13c also contains two regions with three overlapping loops, which can be seen at locations (4, 2) and (4, 5), which are confirmed by the corresponding Shima output. See Figures 14 and 19.

**Figure 19.** Yarn order zoom-in at location (4, 5) in the yarn topology graph of Figure 13: (**a**) Simulated knitted pattern. (**b**) Corresponding zoom-in topology graph.

Once the correctness of the loop stacking order was verified, we tested Algorithm 6 by randomly choosing two locations for each pattern and generating their zoom-in topology graph. The generated zoom-in graphs were visually compared to their associated ordered topology graph that included textual order data. In all cases, they produced consistent, correct outputs. Examples of some of the examined visualizations are the following. A zoom-in topology graph of location (6, 5) in Figure 11c is shown in Figure 15b. A zoom-in graph for location (4, 3) is presented in Figure 12b. A zoom-in topology graph of location (4, 2) in Figure 13c is shown in Figure 14b and the zoom-in at location (4, 5) is presented in Figure 19b. Finally, a zoom-in topology graph of location (5, 3) in Figure 17c is shown in Figure 18b. The confirming Shima output is included with all of these cases.

#### **8. Conclusions**

In this paper, we described algorithms that perform loop order analysis of weftknitted textiles, which build upon the foundational TopoKnit topological data structure and associated query functions. During knitting, loops of yarn may be overlayed on top of each other and then stitched together with another piece of yarn. Loop order analysis aims to determine the front-to-back ordering of these overlapping loops, given a stitch pattern that defines the knitted fabric. The new algorithms are based on the assumption that stitch instructions are executed row-by-row and for each row the instructions can be executed in any temporal order. To make our algorithms knitting-machine-independent, loop order analysis utilizes precedence rules that capture the order that stitch commands are executed when a row of yarn loops are being knitted by a two-bed flat weft knitting machine. Basing the algorithms on precedence rules allows them to adapt to the analysis of fabrics manufactured on a variety of knitting machines that may execute stitch commands in different temporal orders.

Additionally, we have developed visualization methods for displaying the computed loop order information. Specifically, the order of stacked loops may be displayed with textual information that is added to the TopoKnit yarn topology graph. Additionally, a zoom-in visualization algorithm has been developed that graphically displays yarn order at a specific location in a knitted fabric. We have evaluated the robustness of our algorithms and their implementation by conducting tests with 100 randomly generated stitch patterns and comparing our loop ordering results with the simulation outputs from the Shima Seiki SDS-One APEX3 KnitDesign system.

In future work, we plan to utilize these loop order capabilities as part of a system that converts a yarn topology graph into a knot diagram. This transformation will enable additional analysis of a knitted fabric's topology, structure and properties. We also intend to incorporate loop order analysis into future simulations to determine electrical properties that are embedded into a knitted fabric structure.

**Author Contributions:** Conceptualization, L.K., C.A., G.D. and D.E.B.; methodology, L.K. and D.E.B.; software, L.K.; validation, L.K., C.A., G.D. and D.E.B.; resources, C.A. and G.D.; writing original draft preparation, L.K. and D.E.B.; writing—review and editing, L.K., C.A., G.D., and D.E.B.; visualization, L.K.; supervision, D.E.B. and G.D.; project administration, G.D.; funding acquisition, G.D. and D.E.B. All authors have read and agreed to the published version of the manuscript.

**Funding:** This material is based on research sponsored by the US Army Manufacturing Technology Program (US Army DEVCOM) under Agreement number W15QKN-16-3-0001. The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes. Additional financial support was provided by National Science Foundation grants CMMI-1344205 and CMMI-1537720.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

**Conflicts of Interest:** The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.
