Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './App.css';
import * as React from 'react';
import { store, TaskTemplate, TaskToolbar, ToolButtonList } from 'graphlabs.core.template';
import { Matrix } from './Matrix';
import { IEdgeView, IVertexView } from 'graphlabs.core.template/build/models/graph';
import { IEdgeView } from 'graphlabs.core.template/build/models/graph';

class App extends TaskTemplate {

Expand All @@ -20,24 +20,31 @@ class App extends TaskTemplate {
}

calculate() {
const graph = store.getState().graph;
let res = 0;
graph.vertices.forEach((v: IVertexView, index: number) => {
graph.vertices.forEach((w: IVertexView, jndex: number) => {
const e = graph.edges.find((edge: IEdgeView) =>
edge.vertexTwo === v.name && edge.vertexOne === w.name
|| edge.vertexOne === v.name && edge.vertexTwo === w.name);
if (index !== jndex && (this.values[index][jndex] === 0 && e !== void 0
|| this.values[index][jndex] !== 0 && e === void 0)) {
res++;
} else if (index === jndex && this.values[index][jndex] !== 1) {
const graph = store.getState().graph;
let res = 0;
for (let i = 1; i < graph.vertices.length + 1; i++) {
for (let j = 1; j < graph.edges.length + 1; j++) {
if (this.values[i][j] === 1) {
if ((this.myTuple[j - 1][0] === i - 1) || (this.myTuple[j - 1][1] === i - 1)) {
continue;
}
if ((this.myTuple[j - 1][0] !== i - 1) && (this.myTuple[j - 1][1] !== i - 1)) {
res++;
}
}
if (this.values[i][j] === 0) {
if ((this.myTuple[j - 1][0] !== i - 1) && (this.myTuple[j - 1][1] !== i - 1)) {
continue;
}
if ((this.myTuple[j - 1][0] === i - 1) || (this.myTuple[j - 1][1] === i - 1)) {
res++;
}
});
});
// tslint:disable-next-line
console.log(res);
return { success: res === 0, fee: res };
}
}
}

console.log(res);
return { success: res === 0, fee: res };
}

make_vec() {
Expand Down
3 changes: 1 addition & 2 deletions src/Matrix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export class Matrix extends Component<Props> {
count++;
return (
<div className="container" key={i}>
<MatrixRow keys={count} length={this.props.columns} edge={this.props.edges}
get={(el, c) => this.get(el, c, i)}>{this.props.children}</MatrixRow>
<MatrixRow keys={count}length={this.props.columns} get={(el, c) => this.get(el, c, i)}/>
</div>);
})}
</div>
Expand Down
16 changes: 12 additions & 4 deletions src/MatrixCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ export class MatrixCell extends Component<Props, State> {
}
render(): ReactNode {
if (this.props.value === 0) {
return (
<div style={{ border: '1px double black', background: 'white', padding: '6px' }}>
{this.state.value}
</div>);
if (this.state.value === -1) {
return (
<div style={{ border: '0px', background: '', padding: '11px' }}>
{' '}
</div>);
} else {
return (
<div style={{ border: '1px double black', background: 'white', padding: '6px' }}>
{this.state.value}
</div>);
}

} else {
return (
<div style={{ border: '1px double black', background: 'white', padding: '6px' }} onClick={this.handler}>
Expand Down
4 changes: 2 additions & 2 deletions src/MatrixRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { MatrixCell } from './MatrixCell';

interface Props {
edge: [number, number][];
// edge: [number, number][];
keys: number;
length: number;
get: (elem: number, index: number) => void;
Expand All @@ -16,7 +16,7 @@ export class MatrixRow extends Component<Props> {
}

render(): ReactNode {
console.log('VEC: ', this.props.edge);
// console.log('VEC: ', this.props.edge);
let flag = -1;
return new Array(this.props.length).fill(0).map((e, i) => {
if (flag === 0) {
Expand Down