假设您有一个图形graph = nx.read_gml("x.gml")
,并且想放下n
边。有什么快速的方法吗?
答案 0 :(得分:1)
这是使用let appName = 'Test App 534',
tbl = element(by.xpath(
'/html/body/gft-root/section/div[2]/app-onboard-list/div[4]/div[3]/table')),
rows = tbl.all(by.css('tbody > tr'));
rows.reduce((initValue, row, rowIndex)=>{
return row.all(by.css('td:nth-child(1),td:nth-child(6)'))
.getText()
.then((txts)=>{
console.log('row ' +rowIndex+ ', txts: ' + txts)
if(txts[0] === appName && txts[1] === 'Activated') {
console.log('this is matched row');
// when the row meet the condition
// reject a promise with the row index of matched row.
// Promise.reject() will break out the loop
// and code will run into the following catch() section
return Promise.reject(rowIndex);
}
})
}, -1)
.catch((rowIndex)=>{
// use catch() to obtains the row index of matched row via
// Promise.reject(rowIndex) in previous rows.reduce()
console.log('matched row:' + rowIndex);
// click on matched row to enter next page
rows.get(rowIndex).element(by.css('td:nth-child(1) > a')).click();
browser.sleep(4000);
// do other operations and back to the table page
...
return rowIndex;
// still return the rowIndex for as argument for
// the following then() which we will check
// the status of matched row is still Activated
})
.then((rowIndex)=>{
console.log('matched row2:' + rowIndex);
console.log("Check matched row's status is still 'Activated'")
let status = rows.get(rowIndex).element(by.css('td:nth-child(6)')).getText();
expect(status).toEqual('Activated');
return browser.sleep(5000)
})
库中的sample
函数的一种方法。我将random
(要采样的边数)设置为2。
k